a small precompiler question

Discussion in 'C++' started by arjor, May 18, 2008.

  1. arjor

    arjor Guest

    hey guys

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

    #ifndef
    #if !defined

    looks to be the same or is it ?
     
    arjor, May 18, 2008
    #1
    1. Advertising

  2. arjor

    Ian Collins Guest

    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.
     
    Ian Collins, May 18, 2008
    #2
    1. Advertising

  3. arjor

    arjor Guest

    On 19 מ××™, 01:13, 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.
    >
    > --
    > Ian Collins.


    Thanks for the quick reply
     
    arjor, May 18, 2008
    #3
  4. arjor

    red floyd Guest

    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)
     
    red floyd, May 19, 2008
    #4
  5. arjor

    Stefan Ram Guest

    red floyd <> 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.
     
    Stefan Ram, May 19, 2008
    #5
  6. arjor

    Jerry Coffin Guest

    In article <3e67744b-5027-49e6-987a-646f97e27f51@
    34g2000hsh.googlegroups.com>, 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.
     
    Jerry Coffin, May 19, 2008
    #6
  7. arjor

    James Kanze Guest

    On May 19, 2:23 am, -berlin.de (Stefan Ram) wrote:
    > red floyd <> 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:
    Conseils en informatique orientée objet/
    Beratung in objektorientierter Datenverarbeitung
    9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
     
    James Kanze, May 19, 2008
    #7
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Loane Sharp

    precompiler error

    Loane Sharp, Dec 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    482
    Loane Sharp
    Dec 26, 2004
  2. Suzanne Vogel
    Replies:
    2
    Views:
    2,629
    Suzanne Vogel
    Jun 26, 2003
  3. Martin Stich

    Precompiler question

    Martin Stich, Dec 2, 2003, in forum: C++
    Replies:
    7
    Views:
    424
    Chris Theis
    Dec 3, 2003
  4. Werner Nussbaumer

    C Precompiler/Preprocessor Source Code

    Werner Nussbaumer, Mar 5, 2004, in forum: C++
    Replies:
    1
    Views:
    6,104
    Rolf Magnus
    Mar 5, 2004
  5. JohnQ
    Replies:
    22
    Views:
    773
    JohnQ
    Jun 12, 2007
Loading...

Share This Page