I am using a #define to define the size of a queue for serial comms.
A function in a separate bas file needs to dimension (and initiialise) an array of the same size for recieving characters. If i try and reference the identifier declared in the main module i get a compiler error (reference to undefined identifier). if the code is not in a separate bas file i do not get the error.
i infer from this that the scope of identifiers does not extend to functions delcared in other files ?
If this is the case, what is the best way of achieving what i want without resorting to amending code in my separate source file that may be common to several main programs ?
thanks
#define scope
Re: #define scope
That is correct. The scope of a #define extends from the point at which it appears until either 1) the end of the file, or 2) a matching #undef.FFMan wrote:i infer from this that the scope of identifiers does not extend to functions delcared in other files ?
For a constant value that is used in multiple modules, use a Const:
Code: Select all
Public Const MyQueueSize as Integer = 27
- Don Kinzer
Another alternative for defining global constants is to put definitions in your .pjt file with the -D option. Such definitions are global in scope, i.e., they are known in all modules. These should be placed in the .pjt file before the modules in which you want the definition to be in effect.
Code: Select all
-DMyQueueSize=27
- Don Kinzer