Page 1 of 1

Conditional Compiles and Nesting

Posted: 11 February 2008, 18:09 PM
by Don_Kirby
Is suppose the heading pretty much says it all. Can I nest conditional compiler directives?

Code: Select all

#IfDef Something
'compile this code
#IfDef SomethingElse
'Compile more code
#EndIf
#EndIf


-Don

Posted: 11 February 2008, 18:44 PM
by mikep
Yes you can. If you are not sure you can always use the --list compiler option to look at the compiler listing file and you can see what it included.

You can define a conditional symbol either in your source code with a #define or using the compiler -D option.

Posted: 16 February 2008, 14:48 PM
by Don_Kirby
mikep wrote:You can define a conditional symbol either in your source code with a #define or using the compiler -D option.
I have been using the #Define keyword in the IDE, but I've run into a snag. One of my conditional compiles puts the application into a speed test mode, where a few global counter variables are declared, and various tasks add to the counters on each loop. The data is then output via Com1. The problem is that the #define keywords are module level, and I need it to be global.

What's the suggested method to implement a global conditional define, bearing in mind that I'm not using the command line compiler? Is it possible to define in the project file?


-Don

Posted: 16 February 2008, 14:56 PM
by dkinzer
Don_Kirby wrote:Is it possible to define in the project file?
Yes. In addition to naming the project files, you can place nearly any command line option. This is documented in the description of a project file: http://www.zbasic.net/doc/ZBasicRef.php?page=100

Code: Select all

-Dfoo=bar
file1.bas
file2.bas

Posted: 17 February 2008, 5:00 AM
by Don_Kirby
I'm not sure if it's documented or not, but you can also comment out lines in the project file, using the same character ( ' ) as in the IDE. This is very useful for the conditional compile defines.

-Don