a small precompiler question

A

arjor

hey guys

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

#ifndef
#if !defined

looks to be the same or is it ?
 
I

Ian Collins

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.
 
R

red floyd

Ian said:
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)
 
S

Stefan Ram

red floyd said:
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.
 
J

Jerry Coffin

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.
 
J

James Kanze

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top