Home AMX User Forum NetLinx Studio

Odd structure "bug"

I noticed the other day that the compiler doesn't care if you declare a structure type without defining it. In define_variable you can put:
volatile _Fubar fubar

and even though there is no _Fubar in define_type, the compiler doesn't care. Rather odd.
Paul

Comments

  • I talked to Mark Gillner, AMX Canada Trainer, and he figures the compiler will
    simply ignore fubar and _Fubar will be an Integer.

    volatile _Fubar fubar
    compiler interprets to
    VOLATILE Integer _Fubar;
  • Joe HebertJoe Hebert Posts: 2,159
    a_riot42 wrote: »
    I noticed the other day that the compiler doesn't care if you declare a structure type without defining it. In define_variable you can put:
    volatile _Fubar fubar
    

    and even though there is no _Fubar in define_type, the compiler doesn't care. Rather odd.
    Paul

    There is no structure type involved here.
    I talked to Mark Gillner, AMX Canada Trainer, and he figures the compiler will
    simply ignore fubar and _Fubar will be an Integer.

    volatile _Fubar fubar
    compiler interprets to
    VOLATILE Integer _Fubar;

    I don't think that is true.

    I think the compiler will see _Fubar as a VOLATILE INTEGER
    and
    the compiler will see fubar as a NON_VOLATILE INTEGER

    Edit:

    To further clarify
    DEFINE_VARIABLE
    
    volatile _Fubar fubar
    

    Will be seen as:
    DEFINE_VARIABLE
    
    volatile _Fubar	// defaults to INTEGER
    fubar			// defaults to NON_VOLATILE INTEGER
    
  • a_riot42a_riot42 Posts: 1,624
    Yes the compiler must see it as an integer. Without the structure in define_type it has no way of knowing you are trying to declare a structure rather than a default integer. I had a typo in my structure declaration and was surprised that the compiler didn't complain, but what you say makes perfect sense.
    Paul
  • Ah yes, that makes perfect sense.

    DEFINE_VARIABLE
    volatile _Fubar // defaults to INTEGER
    fubar // defaults to NON_VOLATILE INTEGER

    Thank you for the clarification.
Sign In or Register to comment.