c++ - Discouraged pragma use GCC -
c++ - Discouraged pragma use GCC -
header guards necessary in c++ programs, pain when naming conventions strictly enforced - during refactoring. when using gcc (and many other compilers) have alternative in preprocessor command #pragma once. recommendations i've seen against utilize of command (e.g. lack of back upwards before v3.4) aren't convincing regard personal projects. utilize #pragma once if possible.
all said, quote the gcc website giving me pause:
note in general not recommend utilize of pragmas; see function attributes, farther explanation.
maybe it's lower-journeyman-level c++ experience working against me, don't see explanation recommendation @ site pointed link. able explain reasoning behind recommendation in (semi-)layman's terms?
the general recommendation comes fact not there no guarantee other compilers implement #pragma once (or other pragma), there's no guarantee other compilers implement #pragma once same way gcc does. compiler legitimately give exclusively different meaning, or worse, subtly different one. if don't care code beingness portable, can ignore recommendation.
personally, utilize normal #ifndef/#define include guards in own headers, own personal projects. it's not much typing, , guaranteed work everywhere. naming conflicts guard macros have never been issue me, , seek not worry problems don't have.
c++ gcc pragma
Comments
Post a Comment