[Mesa-dev] [PATCH 3/8] glapi/check_table: Remove 'extern "C"' block

Dylan Baker dylan at pnwbakers.com
Mon Dec 4 23:57:01 UTC 2017


Quoting Emil Velikov (2017-11-23 11:04:34)
> On 20 November 2017 at 23:12, Dylan Baker <dylan at pnwbakers.com> wrote:
> > This doesn't actually accomplish what it's meant to do, as extern C
> > doesn't undefine __cplusplus, so the included headers define a template
> > (because __cplusplus is defined), but then that code is in an 'extern
> > "C"' block, and explosion.
> >
> The commit does sound a bit off, admittedly I don't fully grok what
> you're trying to say.
> 
> The extern "C" { } construct annotates anything within as if it were a
> normal C code. Thus functions will have the C linkage (otherwise
> they'll have the C++ mangling) and structs are using the C rules.
> So if you have a C++ header further down the chain it will be
> considered as C and hell will break loose.
> 
> This patch is correct, just sent a fix for glapitable.h, while glapi.h
> was handled with d38839a498b38b745f5bdf6b96fbafa2792670be.
> 
> As-is "struct _glapi_table" will be interpret as C++ one, which may
> not have the same guarantees about sizeof and pointer arithmetic that
> we're using in the test.
> 
> Hope the above provides some inspiration towards a better commit message.
> 
> Thanks
> Emil

So here's the problem I run into:

In file included from ../include/c99_compat.h:28:0,
                 from ../src/util/macros.h:29,
                 from ../src/mapi/glapi/glapi.h:47,
                 from ../src/mapi/glapi/tests/check_table.cpp:28:
../include/no_extern_c.h:47:1: error: template with C linkage
 template<class T> class _IncludeInsideExternCNotPortable;
 ^~~~~~~~
[54/93] Compiling C++ object 'src/gtest/gtest at sta/src_gtest-all.cc.o'.

So, my commit message still makes sense to me, since you can't put a template in
an extern "C" block, and that template is guarded by __cplusplus, which is still
defined even in an extern "C" block.

Do you have a commit message in mind that is better?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20171204/4152f5ef/attachment.sig>


More information about the mesa-dev mailing list