473,757 Members | 7,200 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

what will be the value of #define

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.

Thanking you all

Bye

Mar 2 '07 #1
14 2445
raghu said:
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.
Your #define doesn't affect any identifier by the name of SYATEM_H -
but, presuming you meant SYSTEM_H, its value prior to the #ifndef
depends on whether it exists. If it didn't, then its value after the
#define (in your example) will be 0.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 2 '07 #2
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.

--
Eric Sosman
es*****@acm-dot-org.invalid
Mar 2 '07 #3
On 2 Mar, 13:22, Eric Sosman <esos...@acm-dot-org.invalidwrot e:
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.

Mar 2 '07 #4
Eric Sosman said:
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.
Ah, good point. I realise now that my parallel reply may seem a little
odd, but of course I was thinking of its value when used in
preprocessor directives such as #if.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 2 '07 #5
On Mar 2, 6:28 pm, mark_blue...@po box.com wrote:
On 2 Mar, 13:22, Eric Sosman <esos...@acm-dot-org.invalidwrot e:
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.
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.

Bye

Mar 3 '07 #6
raghu wrote:
On Mar 2, 6:28 pm, mark_blue...@po box.com wrote:
On 2 Mar, 13:22, Eric Sosman <esos...@acm-dot-org.invalidwrot e:
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.

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.
No particular value will be assigned. The symbol FRED_H is defined and
will remain defined until explicitly undefined with an #undef
directive. If you want, you can also do:

#ifndef FRED_H
#define FRED_H 1

/* ... */

#endif /* FRED_H */

Mar 3 '07 #7
"raghu" <ra*********@gm ail.comwrites:
On Mar 2, 6:28 pm, mark_blue...@po box.com wrote:
>On 2 Mar, 13:22, Eric Sosman <esos...@acm-dot-org.invalidwrot e:
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.
[...]
(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.

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.
Raghu, you've posted here a number of times. You've probably already
been advised not to use silly abbreviations like "plz" and "ur". They
just make what you write more difficult to read. If you want us to
take the time to read your articles, take the time to spell out the
words.

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 ;

But there's no reason to care what it expands to, because that's not
what it's used for. In the common idiom where a macro is used as a
header guard, the macro name is *only* used for the purpose of
determining whether it's defined or not, using "#ifndef"; what it
expands to is irrelevant.

--
Keith Thompson (The_Other_Keit h) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Mar 3 '07 #8
Keith Thompson wrote:
"raghu" <ra*********@gm ail.comwrites:
On Mar 2, 6:28 pm, mark_blue...@po box.com 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>

Mar 3 '07 #9
Keith Thompson said:

<snip>
Raghu, you've posted here a number of times. You've probably already
been advised not to use silly abbreviations like "plz" and "ur". They
just make what you write more difficult to read. If you want us to
take the time to read your articles, take the time to spell out the
words.
I have already stopped bothering to read his articles, for precisely
this reason. When he starts posting intelligibly, I will consider
reading what he has to say.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.
Mar 3 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2485
by: Morgan Cheng | last post by:
Hi, In my program module, there are some Constants should be defined to be integer key value of std::map. In the module, methods of a few classes will return std::map containing value indexed by constant integer key value. I am wondering what is a good way to define these constants. 1) #define A = 0 #define B = 1 #define C = 2
7
23555
by: Newbie_sw2003 | last post by:
Where should I use them? I am giving you my understandings. Please correct me if I am wrong: MACRO: e.g.:#define ref-name 99 The code is substituted by the MACRO ref-name. So no overhead. Execution is faster. Where will it be stotred?(Is it in bss/stack/?) FUNCTION:
24
3819
by: David Mathog | last post by:
If this: int i,sum; int *array; for(sum=0, i=0; i<len; i++){ sum += array; } is converted to this (never mind why for the moment):
6
2651
by: Niklaus | last post by:
Hi, Can someone point out what is wrong with this code ? How can i make it better optimize it. When run it gives me seg fault in linux. But windows it works fine(runs for a long time). Do we have something like stack size growing enormously and then saying you can't access ,so a segfault ? It would be helpful if someone can run the code and give me the output. It takes a long time on my PC.
23
2175
by: bjk of course | last post by:
hello, I've stumbled upon this in some code: n = !!x; I've ran it and 'n' is always either 0 or 1. Is '!!' an operator (what's it called?) and is it standard/portable? --
21
13846
by: Helge Jensen | last post by:
I've got some data that has Set structure, that is membership, insert and delete is fast (O(1), hashing). I can't find a System.Collections interface that matches the operations naturally offered by Sets. - ICollection cannot decide containment - IList promises indexability by the natural numbers, which is not achievable (since i hash elements, not sort them). - IDictionary is definatly not setlike. Although I can, of course, define...
669
26171
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic paper written on this subject. On the Expressive Power of Programming Languages, by Matthias Felleisen, 1990. http://www.ccs.neu.edu/home/cobbe/pl-seminar-jr/notes/2003-sep-26/expressive-slides.pdf
53
3186
by: jaso | last post by:
Can you give any comments on this code? I used one goto, is it bad? #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <string.h> #include <assert.h> #define NOT_NULL 1
5
13497
by: =?GB2312?B?17/HvyBaaHVvLCBRaWFuZw==?= | last post by:
Hi, I would like to have someone comments on what's the best practice defining error codes in C. Here's what I think: solution A: using enum pros: type safe. better for debug (some debugger will show the name not only the value) cons: enum can not be forward declared which makes all error codes
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
10072
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3399
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2698
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.