Page 1 of 1

Structure - Already defined

Posted: Tue May 25, 2010 11:11 am
by Perkin
Could you alter the warning for Structures/Prototype/Interface, so if it's already defined, as long as it matches previous definition, it's ignored, rather than having the Warning.
(Same as you do with Constants)


I'm testing quite a few of old codes, and now a lot of structures etc are now defined natively.
If I use an older PB version, without the definitions they need to be included.

Re: Structure - Already defined

Posted: Tue May 25, 2010 12:22 pm
by ts-soft

Re: Structure - Already defined

Posted: Tue May 25, 2010 12:30 pm
by Perkin
I'd seen that and use the compiler directive in newer code.

But when compiling now, the compile is halted with a warning. What I would like is it to continue compiling, as long as the structure is the same as previous definition.

Maybe still put up a warning, but still continue.

Similar to a Constant being defined previously.

Re: Structure - Already defined

Posted: Tue May 25, 2010 7:06 pm
by Josh
i'm thinking about this problem since some days. when i'm writing reusable code in pbi-files, each file has to contain structures, interfaces, constants ... are needed to run code.

to use Defined(Name, Typ) is bull sh..., because when there is a different structure/interface with the same name in a other pbi-file, you will have large problems and it can be very hard to find the bug. on the other side, what is the same function? are this both interfaces the same or not?

Code: Select all

Interface XYZ
  Test (*X)
EndInterface

Code: Select all

Interface XYZ
  Test (*X.IUnknown)
EndInterface
for iid's i'm using the following code:

Code: Select all

      CompilerIf Defined (IID_IUnknown, #PB_Constant) = #False
        IID_IUnknown:
        Data.l $00000000
        Data.w $0000,$0000
        Data.b $C0,$00,$00,$00,$00,$00,$00,$46
      CompilerEndIf
      #IID_IUnknown = "00000000-0000-0000-C000-000000000046"
in this case, the compiler has no problems, when the iid is already defined in a other pbi-file. additionally i can be sure, that the value of the iid is the same as in the other pbi-file.

i havn't tested, but maybe i will use the same system for structures/interfaces. i will make a little program, that's making a simple hashvalue from the structures/interfacetext. when i'm using this hashvalue in the constant, i can be sure, that the structure/interface is the same.

but this workaround doesn't help you with predefined structures/interfaces. so we have to wait for a native solution.