Re: what will be the value of #define
- From: mark_bluemel@xxxxxxxxx
- Date: 2 Mar 2007 05:28:45 -0800
On 2 Mar, 13:22, Eric Sosman <esos...@xxxxxxxxxxxxxxxxxxx> wrote:
raghu wrote:
Hello
I have a doubt plz clarify that
#ifndef SYSTEM_H
#define SYSTEM_H
what will be the value of SYATEM_H after this #define statement and
before that statement.
(Just in case it's a trick question): Impossible to tell,
based on the information provided.
(Assuming it's just a typo): Before the #define, SYSTEM_H
is not defined and has no value at all. After it, SYSTEM_H is
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
(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.
.
- Follow-Ups:
- Re: what will be the value of #define
- From: raghu
- Re: what will be the value of #define
- References:
- what will be the value of #define
- From: raghu
- Re: what will be the value of #define
- From: Eric Sosman
- what will be the value of #define
- Prev by Date: Re: what will be the value of #define
- Next by Date: Re: what will be the value of #define
- Previous by thread: Re: what will be the value of #define
- Next by thread: Re: what will be the value of #define
- Index(es):
Relevant Pages
|
|