
On 6/27/2011 12:59 PM, Stephan T. Lavavej wrote:
[Mateusz Loskot]
Is location of #pragma relevant? Meaning, having #pragma nested in #ifndef include guard vs. placing it in outer scope, makes difference or not?
VC doesn't care where the #pragma once is, but as I recall, other compilers care where the #ifndef is - they prefer it to be on the outside of everything else, except comments.
I doubt if any compiler cares where the #ifndef ( or #if !defined ) is. It is just C++ after all and the preprocessor should handle it according to the C++ standard. It has just become conventional to write: #ifndef SOME_MACRO #define SOME_MACRO // header code #endif to include the header code just once in a translation unit. Surely compilers do not process this any differently when the #ifndef is placed at the beginning of a header file than anywhere else.