Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.c++.moderated    |    Moderated discussion of C++ superhackery    |    33,346 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 31,751 of 33,346    |
|    DeMarcus to All    |
|    Are MACROS good and can the compiler han    |
|    19 Dec 11 23:55:26    |
   
   From: use_my_alias_here@hotmail.com   
      
   Hi,   
      
   I don't like macros.   
   The worst thing I know is macros spread all over the code like:   
      
   DEBUG_PRINT("Some text");   
      
   I still see one benefit with macros; you can remove code completely.   
      
   Therefore I was thinking of the following solution:   
      
   inline void debugPrint( const std::string& text )   
   {   
   #ifndef NDEBUG   
    std::cout << text << std::endl;   
   #endif   
   }   
      
   This way I remove the macros from all over the code. I still have some   
   ugly preprocessor code though (#ifndef) but it's now centralized to one   
   place.   
      
   My question is; if NDEBUG is set, is it common behavior that the   
   compiler will see that debugPrint() is empty and then remove the   
   function call completely so I get the same removal behavior as a macro?   
      
      
   Thanks,   
   Daniel   
      
      
   --   
    [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
    [ comp.lang.c++.moderated. First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca