Tuesday, August 9, 2011

Standards and headers

Every so often I encounter, or hear about, a problem with function definitions when the standard header files are included. Most often its mmap, but sometimes it's something else. Every time I think that I should write something up. Well, it's finally happened, a short paper on how to write portable code using the standard headers.


  1. Thanks for a nice summary, I'll be referring people to it in future as it does a better job than my attempts to explain the feature test macros.

    Listing 9 already includes a using directive, I assume that wasn't meant to be there :)

    Also, C++11 removes the rule that headers must not declare names in the global namespace.

  2. Oops, that was supposed to say "that <cxxx> headers must not ..." but it got filtered out as an html tag

  3. Thanks, no that using namespace std; is not meant to be there.