Home AMX User Forum NetLinx Studio

Preprocessor directives in project settings?

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

Comments

  • DHawthorneDHawthorne Posts: 4,584
    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.
  • yuriyuri Posts: 861
    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.
  • yuriyuri Posts: 861
    Works fine for me.

    oh, i didn't try to compile, i just always used "my way"
  • ColzieColzie Posts: 470
    dnahman wrote: »
    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?
  • yuriyuri Posts: 861
    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?
  • ColzieColzie Posts: 470
    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.
  • sepulvelsepulvel Posts: 4
    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.
Sign In or Register to comment.