Thread: Macro expansion

  1. #1
    Registered User
    Join Date
    Mar 2007
    Posts
    25

    Macro expansion

    I came across a code segment in open source, its like

    Code:
    #define pthread_exit(x)\
    do {\
    	dbg("[%x] pthread_exit(" #x ")\n", pthread_self());\
    	pthread_exit(x);\
    } while(0)
    does it mean that the macro pthread_exit(x) will be expanded
    multiple times (rather indefinite no of times) ...

    & also this code internally does not call exit() system call...
    I am confused how the exit is working in true sense

    plz comment...

    thanks...
    onebrother

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No, macros aren't expanded recursively, so that code will work "as you'd expect it".

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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem building Quake source
    By Silvercord in forum Game Programming
    Replies: 16
    Last Post: 07-11-2010, 09:13 AM
  2. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  3. Quantum Random Bit Generator
    By shawnt in forum C++ Programming
    Replies: 62
    Last Post: 06-18-2008, 10:17 AM
  4. L macro
    By George2 in forum C Programming
    Replies: 1
    Last Post: 08-20-2007, 09:24 AM
  5. Macro Program
    By daspope in forum Windows Programming
    Replies: 5
    Last Post: 04-25-2004, 04:02 AM