Re: what will be the value of #define



Keith Thompson wrote:
"raghu" <ragavakumar@xxxxxxxxx> writes:
On Mar 2, 6:28 pm, mark_blue...@xxxxxxxxx wrote:

<snip>

To explain a little more for "raghu" - the approach is a standard
convention for ensuring that multiple inclusions of header files
(usually due to being nested in other header files) are "harmless".

If my header called "fred.h" has the form:-

#ifndef FRED_H
#define FRED_H
...
#endif /*FRED_H*/

then the first inclusion will have the macro "FRED_H" undefined, will
define the macro (as an empty macro) and do the other declarations,
definitions etc which the header defines.

Any subsequent inclusions will have "FRED_H" defined, so will do
nothing.

Yes you are correct. I am imlementing exactly like this but one thing
I didn't understand what will be the value assigned FRED_H here. when
the processor looks in to it their must be change in the value. Right.
what will be that value.

Thanks for ur reply.

<snip>

Given

#define SYSTEM_H

the identifier SYSTEM_H is a macro that expands to nothing. Any uses
of it *outside a preprocessing directive* (such as #if or #ifdef) will
simply vanish. For example, this:
SYSTEM_H int x SYSTEM_H = 42 SYSTEM_H ;
is exactly equivalent to this:
int x = 42 ;

A minor question:

Is it simply removed or is it replaced by a space character?

<snip>

.



Relevant Pages

  • Re: what will be the value of #define
    ... #ifndef SYSTEM_H ... defined as an object-like macro whose replacement list is empty. ... convention for ensuring that multiple inclusions of header files ... define the macro (as an empty macro) and do the other declarations, ...
    (comp.lang.c)
  • Re: what will be the value of #define
    ... #ifndef SYSTEM_H ... defined as an object-like macro whose replacement list is empty. ... convention for ensuring that multiple inclusions of header files ... define the macro (as an empty macro) and do the other declarations, ...
    (comp.lang.c)
  • Re: what will be the value of #define
    ... #ifndef SYSTEM_H ... defined as an object-like macro whose replacement list is empty. ... To explain a little more for "raghu" - the approach is a standard ... convention for ensuring that multiple inclusions of header files ...
    (comp.lang.c)
  • Re: what will be the value of #define
    ... #ifndef SYSTEM_H ... defined as an object-like macro whose replacement list is empty. ... convention for ensuring that multiple inclusions of header files ... But there's no reason to care what it expands to, ...
    (comp.lang.c)
  • Re: [Luxasm-devel] The "Unified Model"
    ... be done using the _current_ design of the macro system and some ... the directives -- I will address what and where momentarily. ... done in the NASM macros I am using to write Luxasm.) ...
    (alt.lang.asm)