Whether "#pragma once" is or is not deprecated is not the issue.  Rather, the 
problem is that GCC's behavior since it was deprecated is inappropriate for 
writing portable code and arguably violates the intent of the C (9899-1999 
6.10.6) and C++ (14882-1998 16.6) language specifications.

While the specs dictate that recognized pragma directives behave in an 
implementation-defined manner, they also dicatate that unrecognized pragma 
directives are ignored.  It seems that GCC's behavior regarding (deprecated) 
#pragma once falls in a grey area between the two, and it could be argued that 
the behavior should be that of an unrecognized pragma since the directive has 
no effect.

Unfortunately, the behavior of issuing a warning regarding #pragma once, with 
no means to turn it off, breaks code portability while offering no benefit.  If 
the -Werror switch is turned on (considered good practice by many) in concert 
with reasonable warning levels, legitimate portable code fails to compile 
because of this behavior.

Whatever your personal feelings toward #pragma once, it is arrogant (at best) 
to effectively preclude its presence in header files.  Many, many compilers 
recognize this pragma and (claim to) do something useful with it.  If GCC 
chooses not to use it, that's fine, but issuing a warning that can't be turned 
off over an ineffectual, deprecated pragma directive certainly appears to 
violate the spirit of the language specifications.

-- 
           Summary: #pragma misbehavior with -Werror
           Product: gcc
           Version: 3.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: ted at burghart dot org
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=19141

Reply via email to