Home NetLinx Studio

Preprocessor Bug?

sausixsausix Junior MemberPosts: 4
Hi supporters

I've encountered a strange compiler error. A second use of a DEFINE-Symbol throws a
C10233: Symbol [USE_DEVICE] not defined


Works (checked variable in debug window):
PROGRAM_NAME='code'

#DEFINE USE_DEVICE 5001

DEFINE_DEVICE
dvSerial1=USE_DEVICE:1:1


Doesn't work:
PROGRAM_NAME='code'

#DEFINE USE_DEVICE 5001

DEFINE_DEVICE
dvSerial1=USE_DEVICE:1:1
dvSerial2=USE_DEVICE:2:1

Am i doing something wrong?

Studio:4.1.1251
Compiler: 2.5.2.420

I'm temporary unable to update to the latest studio to test it there...


Thanks

Adrian

Comments

  • viningvining X Member Posts: 4,368
    No "use_device" isn't defined, "use_device 5001" is and I'm not sure what the compiler thinks or how it would handle this usage.
    #DEFINE USE_DEVICE_5001
    #IF_DEFINED USE_DEVICE_5001
    dvSerial1=5001:1:1;
    dvSerial2=5001:2:1;
    #END_IF
    

    What are you trying to accomplish? Automatically have code determine if it should should IP, serial or IR for a device that supports multiple comm protocols like TVs in a module written to handle any mode?
  • GregGGregG Just some guy... Posts: 251
    I have never tried using #DEFINE for anything except boolean flags in netlinx, but according to the help file, what you are trying there seems like it should work.

    As a workaround, it looks like this works fine:
    DEFINE_CONSTANT
    USE_DEVICE = 5001
    
    DEFINE_DEVICE
    
    dvSWITCH   = USE_DEVICE:1:1
    dvSAT      = USE_DEVICE:2:1
    



  • a_riot42a_riot42 AMX Wizard Posts: 1,619
    Its kind of weird....this compiles:
    DEFINE_DEVICE
    #DEFINE USE 5001
    
    dvSerial1 = USE:1:1
    //dvSerial2 = USE:1:1
    

    but this doesn't:
    DEFINE_DEVICE
    #DEFINE USE 5001
    
    dvSerial1 = USE:1:1
    dvSerial2 = USE:1:1
    
  • GregGGregG Just some guy... Posts: 251
    The funky part is that help says:
    [B]#DEFINE[/B]
    
       This Compiler Directive defines a symbol to be used only by [FONT=Courier New]#IF_DEFINED[/FONT] and [FONT=Courier New]#IF_NOT_DEFINED[/FONT] directives.
    

    And that is always the only things I ever used it to do.

    But then the help goes on to give examples of using it like this:
    #DEFINE STRING_1 'Hello World'
      #DEFINE STRING_2 "'Hello Letter',65"
      #DEFINE STRING_3 "65,66,67,68,69,70"
      DEFINE_PROGRAM
      PUSH[TP,1]
      {
      SEND_STRING 0,STRING_1 // This will send out 'Hello World'
      SEND_STRING 0,STRING_2 // This will send out 'Hello Letter A'
      SEND_STRING 0,STRING_3 // This will send out 'ABCDEF'
      }
    

    Which seems to go against the "used only by #IF_DEFINED and #IF_NOT_DEFINED" statement.

    I'm going to say it's a bug... in the documentation.
  • sausixsausix Junior Member Posts: 4
    Thanks for verification and help.

    As a programmer coming from other higher programming languages, i often discover weird things in Amx. The documentation is really old and should be updated. Many things are missing there. Would be nice to have an open wiki.

    As already said, i refered to the string literals in the manual examples.
    In this example i wanted to define compile switches f?r each kind of controller. I just switched to using an include file for each type of controller.

    Thanks!
    Adrian Sausenthaler
Sign In or Register to comment.