The macro I defined in B&R Automation Studio does not define

56 Views Asked by At

You can see the macro I defined as RP_AXIS 5 in B&R Automation Studio in the code block I shared. Although I made such a definition, when I compile the project and embed it in the controller, I see that ZRP_AXIS is defined because it is actually at the beginning of the #ifndef starting with CONFIGMANAGEMENT_H. If I define RP_AXIS first after CONFIGMANAGEMENT_H the problem is fixed. As for the problem, there are different systemAxis_t structures according to the projects I use, I change them according to the macros I use. For example, in the project I am using now, I want to pull the relevant systemAxis_T struct using the RP_AXIS definition, but #if commands seem to be ignored. According to the preprocessor definition, RP_AXIS should come and only roll and pitch axes should be active, but ZRP_AXIS axes come to my project.

#define RP_AXIS 10


#ifndef CONFIGMANAGEMENT_H
#define CONFIGMANAGEMENT_H

#if ZRP_AXIS == 5

typedef struct systemAxis_t
{
    double heave;
    double roll;
    double pitch;
}systemAxis_t;

#endif

#if XYZRPQ_AXIS  == 5

typedef struct systemAxis_t
{
    double surge;
    double sway;
    double heave;
    double roll;
    double pitch;
    double yaw;
}systemAxis_t;

#endif

#if Z_AXIS  == 5

typedef struct systemAxis_t
{
    double heave;
}systemAxis_t;

#endif

#if RP_AXIS  == 10


typedef struct systemAxis_t
{
    double roll;
    double pitch;
}systemAxis_t;

#endif
0

There are 0 best solutions below