[cfe-dev] Handling of empty structs in C

Andy Gibbs andyg1001 at hotmail.co.uk
Tue Nov 5 13:05:53 PST 2013


On Tuesday, November 05, 2013 8:44 PM, Richard Smith wrote:
> On Tue, Nov 5, 2013 at 11:19 AM, David Chisnall wrote:
>> On 5 Nov 2013, at 18:19, Reid Kleckner wrote:
>>> IMO extern "C" is a clear indication that the user wants to interoperate
>>> between C and C++.  clang should have this warning on by default in
>>> extern "C" contexts.
>>
>> The problem is that the compiler only sees the extern "C" when compiling
>> in C++ mode, but the author of the header most likely compiles
>> predominantly in C mode.
>
> I'm honestly not worried about this. If someone is writing a header that
> they expect to be usable from language modes X, Y, and Z, and they neither
> try building the code in all of those language modes nor telling us they
> intend to build the code in those modes (by using -Wc++-compat, for instance),
> I think it's reasonable to say that they are beyond our help.
> 
> The -Wc++-compat warning we already have is nice, but we should probably also
> warn (with an on-by-default warning!) if this occurs in an extern "C" block
> in C++.

An extension to this would be to additionally include this warning if the
compiler comes across a use of the __cplusplus macro in C mode, perhaps?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20131105/cdea7fd5/attachment.html>


More information about the cfe-dev mailing list