Page 1 of 1

[Implemented] Defined (Label, #PB_Label)

Posted: Sat Feb 13, 2010 4:11 pm
by Josh
maybe it would be possible, to add labels to the defined-function. then i could do this:

Code: Select all

CompilerIf Defined(IID_NULL, #PB_Label) = #False
  IID_NULL: ; {00000000-0000-0000-0000-000000000000}
    Data.l $00000000
    Data.w $0000, $0000
    Data.b $00, $00, $00, $00, $00, $00, $00, $00
CompilerEndIf
ok, its not importent, i can make also with a constant, but it would be nice

Re: Defined (Label, #PB_Label)

Posted: Sat Feb 13, 2010 4:57 pm
by Demivec
Josh wrote:maybe it would be possible, to add labels to the defined-function. then i could do this:

Code: Select all

CompilerIf Defined(IID_NULL, #PB_Label) = #False
  IID_NULL: ; {00000000-0000-0000-0000-000000000000}
    Data.l $00000000
    Data.w $0000, $0000
    Data.b $00, $00, $00, $00, $00, $00, $00, $00
CompilerEndIf
ok, its not importent, i can make also with a constant, but it would be nice
I had the same idea at one time until I realized that labels are the only "constant" type that can be used before it's defined.

That would mean that the compiler function would have to determine if the label had been used in the code in any way up to that point, whether or not it had been defined yet.

Re: Defined (Label, #PB_Label)

Posted: Sat Feb 13, 2010 6:14 pm
by Josh
hmmmm. when i'm using the code (from my first posting) two times, one of the labels must be the first, which the compiler see. so he knows at the second time, that this label is definied.

at the moment i'm using this:

Code: Select all

CompilerIf Defined(IID_NULL, #PB_Constant) = #False : #IID_NULL = 0
  IID_NULL: ; {00000000-0000-0000-0000-000000000000}
    Data.l $00000000
    Data.w $0000, $0000
    Data.b $00, $00, $00, $00, $00, $00, $00, $00
CompilerEndIf
sorry for my bad english :?

Re: Defined (Label, #PB_Label)

Posted: Fri Feb 19, 2010 8:40 am
by Mistrel
As a workaround you can define a constant that matches your label and check against that.

Re: Defined (Label, #PB_Label)

Posted: Tue Feb 23, 2010 6:45 pm
by Josh
Mistrel wrote:As a workaround you can define a constant that matches your label and check against that.
you mean like in my second posting?

the best would be, if Defined(....) makes the same like constants. if it is two times the same, the compiler do nothing. if there are two different contents, the compiler message an error. i know, thats a little bit tricky, because there is no fixed length for the data section, but maybe it could be used the data between the label and the next label for comparsion.