Skip to content

Namespace and extern "C" gives problems with forward struct declarations #9534

@DimitryAndric

Description

@DimitryAndric
Bugzilla Link 9162
Resolution FIXED
Resolved on Oct 09, 2011 17:58
Version trunk
OS All
CC @DougGregor,@pwo

Extended Description

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 4.3.10.1, and they all accept it without any
complaint.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillac++

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions