Page 1 of 1

#ifndef

Posted: 27 Feb 2005 17:58
by gambrose
Can the #ifndef be used with macros?

I have the following code:

Code: Select all

#ifndef Printf_Output(character)
     #define Printf_Output(character) asm nop;


which generates this error:

[quote]f:/microc code/printf/printf_formatter.h:3: error: Excessive token sequence "(character)"
    #ifndef Printf_Output(character)
    from F:/MicroC code/Printf/Short2Ascii.c: 1:    #include "Printf_Formatter.H"
1 error in preprocessor.[/quote]

when i have this code:

[code]#define Printf_Output(character) LCD_Chr_CP(character);


in my main program file.

Re: #ifndef

Posted: 28 Feb 2005 18:12
by nikola
gambrose wrote:Can the #ifndef be used with macros?
Yes, they can. The code you need is:

Code: Select all


  #define Printf_Output(character) asm nop;


You were close :wink:

--
best regards,
Nikola

Posted: 28 Feb 2005 18:38
by gambrose
Thanks but I still have a problem

I have a C file with a formatter function in it that outputs to Printf_Output

This has a header file which includes

#define Printf_Output(character) asm nop;


But when I use



In the main C file it dose not load the LCD_Chr_CP function so I assume it is not passing the #define of Printf_Output to formatter header file.

(it works fine with #define Printf_Output(character) LCD_Chr_CP(character); in the formatter header file)

Am I correct in thinking this is what should be happening?

Re: #ifndef

Posted: 08 Mar 2013 14:45
by Bangon Kali
This may help.