Thread: Warning on an ifndef directive

  1. #1
    l'Anziano DavidP's Avatar
    Join Date
    Aug 2001
    Plano, Texas, United States

    Warning on an ifndef directive

    My code is actually compiling and running fine, but I am getting 1 warning which I would like to eliminate (I like to see 0 errors and 0 warnings instead of 0 errors and 1 warning )

    Here is the code:
    #ifndef sqr(x)
    #define sqr(x)		x*x
    The warning is stated thus:
    inc/path.h:32:12: warning: extra tokens at end of #ifndef directive
    I assume this has to do with the parser finding some extra tokens after the first line (the #ifndef line), but before the second line (the #define line).

    Anyone know what's up here?
    My Website

    "Circular logic is good because it is."

  2. #2
    Registered User
    Join Date
    Oct 2001
    >#ifndef sqr(x)
    I'm no expert on the preprocessor, but I think you can just write:
    #ifndef sqr
    My compiler actually didn't give a warning with either version, so I'm not sure which is more correct.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    New Zealand
    #ifndef sqr
    is all it should say.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 10
    Last Post: 07-10-2008, 03:45 PM
  2. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  3. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  4. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 06:39 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 05:06 PM