Preprocessor directives in project settings?
dnahman
Posts: 28
Hi all,
Is there any way to define a compiler preprocessor directive in the preferences for a given system within a project? Similar to how Microsoft Visual C++ allows you to put #DEFINES into the preferences which generate the Makefile that gets executed to build your program.
I have a situation where I need to include one of two different axi files depending on what system I'm compiling for. I would like to have in my master axs file:
#IF_DEFINED GATE
include 'necIS8'
#ELSE
include 'christie'
#END_IF
My workaround for this is to move the main body of my code into an axi file (including the directives above), and then have two master axs files - gate.axs and notgate.axs.
gate.axs contains only
PROGRAM_NAME='gate.axs 20070207 10:44:32'
#DEFINE GATE
include 'mainbody'
and notgate.axs contains only :
PROGRAM_NAME='gate.axs 20070207 10:44:32'
include 'mainbody'
Any thoughts would be appreciated.
Thanks,
David
Is there any way to define a compiler preprocessor directive in the preferences for a given system within a project? Similar to how Microsoft Visual C++ allows you to put #DEFINES into the preferences which generate the Makefile that gets executed to build your program.
I have a situation where I need to include one of two different axi files depending on what system I'm compiling for. I would like to have in my master axs file:
#IF_DEFINED GATE
include 'necIS8'
#ELSE
include 'christie'
#END_IF
My workaround for this is to move the main body of my code into an axi file (including the directives above), and then have two master axs files - gate.axs and notgate.axs.
gate.axs contains only
PROGRAM_NAME='gate.axs 20070207 10:44:32'
#DEFINE GATE
include 'mainbody'
and notgate.axs contains only :
PROGRAM_NAME='gate.axs 20070207 10:44:32'
include 'mainbody'
Any thoughts would be appreciated.
Thanks,
David
0
Comments
#IF_NOT_DEFINED __NETLINX__
TP = 128
#END_IF
#IF_DEFINED __NETLINX__
TP = 128:1:1
#END_IF
Works fine for me.
oh, i didn't try to compile, i just always used "my way"
I have this same situation, and had come up with this solution as well. Any other clever ways to do this?
Previously I've created a u_room structure that contains all the info about each room...IP address and any other unique information that I use later as necessary. ALL the rooms are defined. At startup I'd loop through all the u_rooms to determine the current room (based on IP) and track a pointer to the proper u_room.
I'd like to get away from this method. I'd like it to be almost modular (I have trouble wrapping my head around how I could make my entire program a module) where I can pass in a little info to have the program run slightly different depending on the room.
Perhaps dnahman's solution is the best way?
Maybe that's something you could try?
I've gotten caught before spending twice as much time developing uber-flexible solutions instead of just hard-coding and being done with it.
I've decided for this project I'm just going to do unique Master stubs calling a common Include which contains the majority of the code. Some compiler directives will help load the proper modules.
Thanks for the help!
We did several projects in the past, with up to 120 systems, devided into several different room types. Like dnahman does, we created AXIs for each room type, and unique AXS main files for each master, where the correct room type AXI is included. We managed this very accurate, i.e. if there is just a different DVD player in 2 rooms, we created different room type AXIs.
In the systems' axs files we included a routine which checks for the system number of the master. If it differs from the system number we defined in the axs, the master is reconfigured and rebooted by code.
Find attached a screenshot of the workspace. We managed the different room types as projects in the workspace.