The only way to access a value from the C-application is in native code. It doesn’t matter whether the value comes from a #define or from a variable.
In the unit where we want to access a value from C-code we need to include the header file with the definition or declaration of the access function or definition. Get an "Inline Code"-brick from the Gallery into this unit and set your include e.g.
#include “Environment.h”
Note: It is recommended to change the order of the members of your unit to have the inline code back most. The order determines the sequence for the code generation starting from bottom to top. This ensures that the #include is inserted in the generated code at the beginning of the file.
Now we assume that there is a definition in the header file Environment.h e.g.
#define ENVIRONMENT_NO_OF_PORTS 4
To access this value we drag a new method in the class where we want to access the #define, rename the method to GetNoOfPorts() and set the return value to int32. In the editor window we can now implement the native code.
var int32 result = 0;
$if !$Prototyper
native( result )
{
result = ENVIRONMENT_NO_OF_PORTS;
}
$endif
return result;