From: pasa@lib.hu   
      
   On 1/22/2013 8:01 PM, james.d.mclaughlin@googlemail.com wrote:   
   > #include    
   > #include    
   > #include    
      
   IIRC the rules are something like this:   
   - original C headers (like stdio.h) put all names in :: but are allowed   
   to also add them to std::   
   - the new headers (like cstdio) put all names in std:: but are allowed   
   to also add them at ::   
      
      
   > Does anyone know of any reason why someone would want to #include both   
   > stdio.h and cstdio in the same file? More importantly, are there any   
   > potential pitfalls to doing this?   
      
   If the implementation is conforming there should not be any problem, and   
   having both includes ensure all names in both places.   
      
   Why would someone want that is honestly beats me -- in code under my   
   control I'd allow exactly one and forbid the other to avoid confusion.   
   Due to the fact the names can appear in the "other" place, plus that any   
   standard header allows to include any number of other standard headers   
   means that any of the above includes may is allows to leave you with all   
   C standard defined symbols in the global namespace. Then why fight them?   
   Easiest way is IMHO to use them from global and treat them as reserved.   
      
   > If there are, can I just fix them by   
   > commenting out the line with stdio.h?   
      
   No, if the TU uses the symbols in global. You first need to consolidate   
   the usage to one form or the other, then can remove the excess include.   
      
   > A slightly less important question as well - does anyone know of any   
   > reason not to change to in the above?   
      
   Not being forced to add noise to the code in form of std:: prefixes   
   sounds like a **** good reason to me. :)   
      
   > I can easily   
   > go through the file putting std:: before function names and the like.   
      
   And your answer to the obvious review question "What is the benefit of   
   that?" "How hat make the code simpler and better to handle?" is?   
      
      
   --   
    [ 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)   
|