Preprocessor directives in project settings?
dnahman
Junior Member
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
Comments
-
The pre-compiler directives are identical to what you are used to in C++. #DEFINE, #IF_DEFINED, #END_IF, #INCLUDE are all supported and work as you expect them to.
-
the #ELSE won't work. This will work:
#IF_NOT_DEFINED __NETLINX__
TP = 128
#END_IF
#IF_DEFINED __NETLINX__
TP = 128:1:1
#END_IF -
yuri wrote:the #ELSE won't work.
Works fine for me. -
NMarkRoberts wrote:Works fine for me.
oh, i didn't try to compile, i just always used "my way" -
I have a situation where I need to include one of two different axi files depending on what system I'm compiling for.
...
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
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? -
I've seen a project where there was a Netlinx project, that created other Netlinx .apw files (sounds neat doesn't it?) according to certain settings about rooms/ip addresses/equipment
Maybe that's something you could try? -
That does sound neat, but a bit much for what I'm trying to do. I'm not creating an AMX Home type system, I just have a few rooms to program that are similar but not exact.
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. -
I have a similar situation. I'm trying to have one source file that works in several rooms. The necessary code for each room is separated into AXI files, I just need a way to query for a unique number so I can iclude the proper AXI file. Is there a way to do this using the system ID or the UNIQUE_ID??
Thanks for the help! -
There is no method to get the System Number or unique ID (serial number) at compile time.
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.
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums