problem in macro

This is a discussion on problem in macro within the C Programming forums, part of the General Programming Boards category; Originally Posted by laserlight The C Standard does not seem to forbid a semi-colon at the end of a macro's ...

  1. #16
    Registered User ralu.'s Avatar
    Join Date
    Feb 2009
    Location
    Bucharest, RO
    Posts
    32
    Quote Originally Posted by laserlight View Post
    The C Standard does not seem to forbid a semi-colon at the end of a macro's definition, so the only errors will result from the "normal" usage of the macro, not its definition.
    That comment of mine was not to the semi-colon wrong use. Please pay more attention before making a comment. it is true c compiler does not forbid the semi-colon... but i gave above an example why is not a good idea using it like that.

  2. #17
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    22,304
    Quote Originally Posted by matsp
    I think ralu's comment was to my comment that the macro originally posted provides the right result - it does make interesting use of the || operator, which could, as ralu points out, lead to result of 0 or 1.
    Ah yes, I see it now. I got confused by ralu.'s excessively strong wording, i.e., 'you must not put ";"' instead of 'you should not put ";"'.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #18
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by ralu. View Post
    That comment of mine was not to the semi-colon wrong use. Please pay more attention before making a comment. it is true c compiler does not forbid the semi-colon... but i gave above an example why is not a good idea using it like that.
    But it would also help if you quoted the part that you are referring to - then it is clear what particular post your comment is referring to, rather than "this may apply to any of the above posts". No, I'm not perfect, I make the same mistake myself. But particularly on "hot" threads, it is often that comments "cross in the post", so you it's hard to determine which post is referring to which previous comment.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 09:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 03:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 07:54 PM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 05:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21