From: Brian T. <bri...@ya...> - 2003-04-18 15:54:32
|
Hi, You are correct that the code is being compiled in everytime. There are two forms of the #if precompile directives, #ifdef/#ifndef and #if. You are using the #ifdef which compiles in if the variable is defined (no matter the value). You have defined it in every case. Instead you want to use the simple #if: #define DEBUG_WORK 1 #if DEBUG_WORK printf("blahblah"); #endif or you could also say #if DEBUG_WORK == 1 OR #define DEBUG_WORK 0 #if !DEBUG_WORK or #if DEBUG_WORK == 0 The other fix to your code is to simply comment out the #define line, then the #ifdef will work correctly (the variable won't be defined so the test will return false). Hope this explains it, Brian Tyler --- roelof 't Hooft <ro...@it...> wrote: > Hi, > > I am trying to use #ifdef and #endif. > I have defined a 'variable' like this at the very > beginning > of the source file, right after the #include's : > > #define DEBUG_WORK 0 > > And somewhere in the source I have : > > #ifdef DEBUG_WORK > printf("blahblah"); > #endif > > > It doesn't matter if I set the #define DEBUG_WORK to > 0, > FALSE, false, 1, TRUE or true it still is included > in the hex file. > > #ifdef is only mentioned in the sdccman.html > (node18, preprocessor) > and nothing else or more. > > Any clues to what I'm missing or doing wrong ? > > I'm using sdcc 2.3.3, about a month old with these > command line options : > --model-small --code-loc 0x0000 --stack-loc 128 > --iram-size 0x80 --stack-auto > > > > PS: this is part of the output when I try to compile > the cvs checkout > from this morning on debain linux : > > gcc -Wall -pipe -ggdb -g -O2 -I. -I.. > -I../support/Util -c SDCCdebug.c -o SDCCdebug.o > gcc -Wall -pipe -ggdb -g -O2 -I. -I.. > -I../support/Util -c cdbFile.c -o cdbFile.o > gcc -Wall -pipe -ggdb -g -O2 -I. -I.. > -I../support/Util -c SDCClex.c -o SDCClex.o > SDCC.lex:45: redefinition of `yylineno' > <stdout>:334: `yylineno' previously defined here > SDCC.lex:50: syntax error before "YY_PROTO" > SDCC.lex: In function `stringLiteral': > SDCC.lex:376: `yytext_ptr' undeclared (first use in > this function) > SDCC.lex:376: (Each undeclared identifier is > reported only once > SDCC.lex:376: for each function it appears in.) > {standard input}: Assembler messages: > {standard input}:5838: Error: symbol `yylineno' is > already defined > make[1]: *** [SDCClex.o] Error 1 > make[1]: Leaving directory `/home/roelofh/sdcc/src' > make: *** [sdcc-cc] Error 2 > > I allready did 'make clean' and 'make realclean', > same result. > > > > -- > roelof 't Hooft > --------------------------------------------------------- > Electronische kompassen voor navigatie in de > beroepsvaart > --------------------------------------------------------- > I.T. Holland tel : +31 (0)172 > 445607 > Houtweg 18 fax : +31 (0)172 > 436290 > 2461GR Ter Aar > http://www.itholland.com/ > Holland > ro...@it... > --------------------------------------------------------- > > > ------------------------------------------------------- > This sf.net email is sponsored by:ThinkGeek > Welcome to geek heaven. > http://thinkgeek.com/sf > _______________________________________________ > Sdcc-user mailing list > Sdc...@li... > https://lists.sourceforge.net/lists/listinfo/sdcc-user __________________________________________________ Do you Yahoo!? The New Yahoo! Search - Faster. Easier. Bingo http://search.yahoo.com |