Global Inside Procedure
Posted: Fri Apr 05, 2013 8:03 pm
Hello,
For the purpose of binding function pointers to PB global variables from an external library, I'm using a Macro inside a Procedure which declare a Global variable for each function (and retrieve the actual pointer of the functions and set the variables).
Using this Macro allow me to type the function names once, instead of first declaring the global variables outside the procedure then use the Macro for which I have to retype the function names (and I have more than 500 functions). It makes the source code clearer and shorter.
These variables can then be accessed *outside* this Procedure, even with EnableExplicit on.
My question is: while it works perfectly well, is it 'legal' in a PureBasic sense to use the Global statement *inside* a Procedure ?
Because I don't want to have the "native types can't be used with pointers" syndrome/surprise in a near future by learning that 'this' new version of PureBasic forbid the use of the Global statement from within a Procedure.
So.. should I be confident or worried using the Global statement inside Procedures ?
Thanks,
Guy.
For the purpose of binding function pointers to PB global variables from an external library, I'm using a Macro inside a Procedure which declare a Global variable for each function (and retrieve the actual pointer of the functions and set the variables).
Using this Macro allow me to type the function names once, instead of first declaring the global variables outside the procedure then use the Macro for which I have to retype the function names (and I have more than 500 functions). It makes the source code clearer and shorter.
These variables can then be accessed *outside* this Procedure, even with EnableExplicit on.
My question is: while it works perfectly well, is it 'legal' in a PureBasic sense to use the Global statement *inside* a Procedure ?
Because I don't want to have the "native types can't be used with pointers" syndrome/surprise in a near future by learning that 'this' new version of PureBasic forbid the use of the Global statement from within a Procedure.
So.. should I be confident or worried using the Global statement inside Procedures ?
Thanks,
Guy.