https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85729

            Bug ID: 85729
           Summary: including c++ headers within extern "C" linkage
                    specification
           Product: gcc
           Version: 8.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: nsz at gcc dot gnu.org
  Target Milestone: ---

some code does not include c++ headers in the top level but has

extern "C" {
#include <cstring>
}

this is invalid c++ (similar to bug 19373 where the include is under
namespace specification), but this can be made to work for c*
headers by adding explicit extern "C++" annotations where necessary
in libstdc++ headers. (currently it happens to work with a normal
gnu toolchain, because then glibc provides the string function
prototypes with explicit extern "C++", but with other setups it
can fail.)

alternatively gcc could try to warn about such header usage,
the relevant text in the spec is

[using.headers]:
 A translation unit shall include a header only outside of any external
 declaration or definition, and shall include the header lexically
 before the first reference in that translation unit to any of the
 entities declared in that header. No diagnostic is required.

Reply via email to