Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > a small precompiler question

Reply
Thread Tools

a small precompiler question

 
 
arjor
Guest
Posts: n/a
 
      05-18-2008
hey guys

i was wondering what's the difference between the following commands:

#ifndef
#if !defined

looks to be the same or is it ?
 
Reply With Quote
 
 
 
 
Ian Collins
Guest
Posts: n/a
 
      05-18-2008
arjor wrote:

[it's preprocessor, not precompiler]

> hey guys
>
> i was wondering what's the difference between the following commands:
>
> #ifndef
> #if !defined
>
> looks to be the same or is it ?


They are synonymous.

--
Ian Collins.
 
Reply With Quote
 
 
 
 
arjor
Guest
Posts: n/a
 
      05-18-2008
On 19 מאי, 01:13, Ian Collins <(E-Mail Removed)> wrote:
> arjor wrote:
>
> [it's preprocessor, not precompiler]
>
> > hey guys

>
> > i was wondering what's the difference between the following commands:

>
> > #ifndef
> > #if !defined

>
> > looks to be the same or is it ?

>
> They are synonymous.
>
> --
> Ian Collins.


Thanks for the quick reply
 
Reply With Quote
 
red floyd
Guest
Posts: n/a
 
      05-19-2008
Ian Collins wrote:
> arjor wrote:
>
> [it's preprocessor, not precompiler]
>
>> hey guys
>>
>> i was wondering what's the difference between the following commands:
>>
>> #ifndef
>> #if !defined
>>
>> looks to be the same or is it ?

>
> They are synonymous.
>


They are synonymous, except that !defined can be used in a preprocessor
expression...

e.g.:

#if !defined(THIS) && defined(THAT)

 
Reply With Quote
 
Stefan Ram
Guest
Posts: n/a
 
      05-19-2008
red floyd <(E-Mail Removed)> writes:
>>>i was wondering what's the difference between the following commands:
>>>#ifndef
>>>#if !defined

>>They are synonymous.

>They are synonymous, except that !defined can be used in a
>preprocessor expression...


This is not an exception to the assertion that these commands
are synonymous, because assertions about whether !defined
can be used in such an expression are not in the scope of the
assertion of the synonymity of these two preprocessor
commands.

For another example, the statements i++; and ++i; are
synonymous, but the expressions i++ and ++i are not.
But the assertion about the expressions is not an exception
to the assertion about the statements.

However, the above preprocessor commands actually are not
commands at all, but directives - preprocessing directives.

 
Reply With Quote
 
Jerry Coffin
Guest
Posts: n/a
 
      05-19-2008
In article <3e67744b-5027-49e6-987a-646f97e27f51@
34g2000hsh.googlegroups.com>, http://www.velocityreviews.com/forums/(E-Mail Removed) says...
> hey guys
>
> i was wondering what's the difference between the following commands:
>
> #ifndef
> #if !defined
>
> looks to be the same or is it ?


As-is, they're synonyms. The latter allows combinations of boolean logic
such as:

#if !defined(x) && !defined(y)

which are clumsier to produce with #ifndef.

--
Later,
Jerry.

The universe is a figment of its own imagination.
 
Reply With Quote
 
James Kanze
Guest
Posts: n/a
 
      05-19-2008
On May 19, 2:23 am, (E-Mail Removed)-berlin.de (Stefan Ram) wrote:
> red floyd <(E-Mail Removed)> writes:
> >>>i was wondering what's the difference between the following commands:
> >>>#ifndef
> >>>#if !defined
> >>They are synonymous.

> >They are synonymous, except that !defined can be used in a
> >preprocessor expression...


> This is not an exception to the assertion that these commands
> are synonymous, because assertions about whether !defined
> can be used in such an expression are not in the scope of the
> assertion of the synonymity of these two preprocessor
> commands.


Yes and no. In the first case, you have the preprocessor
command #ifndef, in the second the preprocessor command #if. It
really depends on what you consider is a "preprocessor command".

> For another example, the statements i++; and ++i; are
> synonymous, but the expressions i++ and ++i are not.
> But the assertion about the expressions is not an exception
> to the assertion about the statements.


Yes, but he clearly doesn't have a complete preprocessor
directive in either case, since there's no symbol after the
#ifndef or the defined.

> However, the above preprocessor commands actually are not
> commands at all, but directives - preprocessing directives.


What he wrote are not legal preprocessing directives. More is
needed. The first is considerably more restrictive with regards
to what that more can be.

--
James Kanze (GABI Software) email:(E-Mail Removed)
Conseils en informatique oriente objet/
Beratung in objektorientierter Datenverarbeitung
9 place Smard, 78210 St.-Cyr-l'cole, France, +33 (0)1 30 23 00 34

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ Precompiler: Same as C Precompiler? JohnQ C++ 22 06-12-2007 11:40 AM
precompiler error Loane Sharp ASP .Net 0 12-26-2004 09:11 PM
C Precompiler/Preprocessor Source Code Werner Nussbaumer C++ 1 03-05-2004 01:11 PM
Precompiler question Martin Stich C++ 7 12-03-2003 08:28 AM
Re: circular dependencies & globals - avoid w/ precompiler directives?betterdesign suggestions? Suzanne Vogel C++ 2 06-26-2003 12:25 AM



Advertisments