[LLVMbugs] [Bug 9162] New: Namespace and extern "C" gives problems with forward struct declarations

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Mon Feb 7 12:11:11 PST 2011


           Summary: Namespace and extern "C" gives problems with forward
                    struct declarations
           Product: clang
           Version: trunk
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++
        AssignedTo: unassignedclangbugs at nondot.org
        ReportedBy: dimitry at andric.com
                CC: llvmbugs at cs.uiuc.edu, dgregor at apple.com

Clang has a problem compiling the gstreamer backend for KDE's phonon
library.  I encountered this issue with trunk r125004.  The reduced C++
code goes like this:

namespace Gstreamer {
  extern "C" {
    typedef struct _ArtsSink ArtsSink;
    struct _ArtsSink {
      int sink;
  int arts_sink_get_type()
    return sizeof(ArtsSink);

Compiling this with clang++ gives:

fwddecl.cpp:10:12: error: invalid application of 'sizeof' to an incomplete type
'ArtsSink' (aka 'Gstreamer::_ArtsSink')
    return sizeof(ArtsSink);
           ^     ~~~~~~~~~~
fwddecl.cpp:3:20: note: forward declaration of 'Gstreamer::_ArtsSink'
    typedef struct _ArtsSink ArtsSink;
1 error generated.

Granted, it is a bit weird how the KDE guys forward declare the
_ArtsSink struct, but as far as I can see, it should still compile.

I tried this fragment with g++ 4.2.1 (FreeBSD base system compiler), g++
4.5.3, and Coumeau, and they all accept it without any

Note: the error goes away when you eliminate either the namespace or the
'extern "C"' block.  Both are required to produce the error.

Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the llvm-bugs mailing list