Re: [Mesa-dev] [PATCH] include: Add helper header to help trap includes inside extern C.
On 2015-05-13 10:42, Jason Ekstrand wrote: On May 13, 2015 8:01 AM, "kallisti5" wrote: src/mesa/drivers/haiku/swrast/SoftwareRast.cpp:28: > include/no_extern_c.h:47:1: error: template with C linkage > > template class _IncludeInsideExternCNotPortable; > > Any alternative fix ideas besides me adding a if !defined(__HAIKU__) to include/no_extern_c.h? Please do not do that! The whole point of this patch is to catch places where headers are included inside an extern "C" block. This patch makes them a compile error instead of being silently wrong. The correct solution is to fix the haiku platform integration so it doesn't do this. --Jason Yeah, I had a chat in IRC and determined that I need to add extern "C" a few places within Mesa instead of doing a bulk extern "C" to the mesa C headers. One example is glapi_priv lacks any extern "C" (ifdef C++ wrapped) I'll begin submitting patches to the ML over the next few days. Thanks! -- Alex ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] include: Add helper header to help trap includes inside extern C.
On May 13, 2015 8:01 AM, "kallisti5" wrote: > > On 2014-12-11 16:14, Jose Fonseca wrote: >> >> From: José Fonseca >> >> This is just to help repro and fixing these issues with any C++ compiler -- >> >> commiting this will of course wait until all issues are addressed. >> >> >> $ scons src/glsl/ >> scons: Reading SConscript files ... >> Checking for GCC ... yes >> Checking for Clang ... no >> Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes >> Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes >> Checking for XF86VIDMODE (xxf86vm)... yes >> Checking for DRM (libdrm >= 2.4.38)... yes >> Checking for UDEV (libudev >= 151)... yes >> warning: LLVM disabled: not building llvmpipe >> scons: done reading SConscript files. >> scons: Building targets ... >> scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl >> Compiling src/glsl/ast_array_index.cpp ... >> Compiling src/glsl/ast_expr.cpp ... >> Compiling src/glsl/ast_function.cpp ... >> Compiling src/glsl/ast_to_hir.cpp ... >> Compiling src/glsl/ast_type.cpp ... >> Compiling src/glsl/builtin_functions.cpp ... >> In file included from include/c99_compat.h:28:0, >> from src/mapi/u_compiler.h:4, >> from src/mapi/u_thread.h:47, >> from src/mapi/glapi/glapi.h:47, >> from src/mesa/main/mtypes.h:42, >> from src/mesa/main/errors.h:47, >> from src/mesa/main/imports.h:41, >> from src/mesa/main/core.h:44, >> from src/glsl/builtin_functions.cpp:58: >> include/no_extern_c.h:48:1: error: template with C linkage >> template class _IncludeInsideExternCNotPortable; >> ^ > > > Good morning, > > This change breaks all of the Haiku code as we use a *lot* of C++ code inside > of Mesa (well, all the OS interfaces are C++ that wrap the Mesa C) > > /Builds/mesa> find . -name "*.cpp" | grep haiku > ./src/egl/drivers/haiku/egl_haiku.cpp > ./src/gallium/targets/haiku-softpipe/GalliumContext.cpp > ./src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp > ./src/mesa/drivers/haiku/swrast/SoftwareRast.cpp > > > Example: > Compiling src/util/u_atomic_test.c ... > > In file included from include/c99_compat.h:28:0, > from include/c11/threads.h:38, > from src/mesa/main/mtypes.h:39, > from src/mesa/main/errors.h:42, > from src/mesa/main/imports.h:44, > from src/mesa/main/context.h:52, > from src/mesa/drivers/haiku/swrast/SoftwareRast.h:20, > from src/mesa/drivers/haiku/swrast/SoftwareRast.cpp:14: > include/no_extern_c.h:47:1: error: template with C linkage > > template class _IncludeInsideExternCNotPortable; > ^ > In file included from include/c99_compat.h:28:0, > from src/gallium/include/pipe/p_compiler.h:32, > from src/gallium/auxiliary/util/u_math.h:42, > from src/mesa/main/macros.h:35, > from src/mesa/main/colormac.h:37, > from src/mesa/drivers/haiku/swrast/SoftwareRast.cpp:28: > include/no_extern_c.h:47:1: error: template with C linkage > > template class _IncludeInsideExternCNotPortable; > > Any alternative fix ideas besides me adding a if !defined(__HAIKU__) to include/no_extern_c.h? Please do not do that! The whole point of this patch is to catch places where headers are included inside an extern "C" block. This patch makes them a compile error instead of being silently wrong. The correct solution is to fix the haiku platform integration so it doesn't do this. --Jason > -- Alex > > ___ > mesa-dev mailing list > mesa-dev@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/mesa-dev ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] include: Add helper header to help trap includes inside extern C.
On 2014-12-11 16:14, Jose Fonseca wrote: From: José Fonseca This is just to help repro and fixing these issues with any C++ compiler -- commiting this will of course wait until all issues are addressed. $ scons src/glsl/ scons: Reading SConscript files ... Checking for GCC ... yes Checking for Clang ... no Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes Checking for XF86VIDMODE (xxf86vm)... yes Checking for DRM (libdrm >= 2.4.38)... yes Checking for UDEV (libudev >= 151)... yes warning: LLVM disabled: not building llvmpipe scons: done reading SConscript files. scons: Building targets ... scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl Compiling src/glsl/ast_array_index.cpp ... Compiling src/glsl/ast_expr.cpp ... Compiling src/glsl/ast_function.cpp ... Compiling src/glsl/ast_to_hir.cpp ... Compiling src/glsl/ast_type.cpp ... Compiling src/glsl/builtin_functions.cpp ... In file included from include/c99_compat.h:28:0, from src/mapi/u_compiler.h:4, from src/mapi/u_thread.h:47, from src/mapi/glapi/glapi.h:47, from src/mesa/main/mtypes.h:42, from src/mesa/main/errors.h:47, from src/mesa/main/imports.h:41, from src/mesa/main/core.h:44, from src/glsl/builtin_functions.cpp:58: include/no_extern_c.h:48:1: error: template with C linkage template class _IncludeInsideExternCNotPortable; ^ Good morning, This change breaks all of the Haiku code as we use a *lot* of C++ code inside of Mesa (well, all the OS interfaces are C++ that wrap the Mesa C) /Builds/mesa> find . -name "*.cpp" | grep haiku ./src/egl/drivers/haiku/egl_haiku.cpp ./src/gallium/targets/haiku-softpipe/GalliumContext.cpp ./src/gallium/targets/haiku-softpipe/SoftwareRenderer.cpp ./src/mesa/drivers/haiku/swrast/SoftwareRast.cpp Example: Compiling src/util/u_atomic_test.c ... In file included from include/c99_compat.h:28:0, from include/c11/threads.h:38, from src/mesa/main/mtypes.h:39, from src/mesa/main/errors.h:42, from src/mesa/main/imports.h:44, from src/mesa/main/context.h:52, from src/mesa/drivers/haiku/swrast/SoftwareRast.h:20, from src/mesa/drivers/haiku/swrast/SoftwareRast.cpp:14: include/no_extern_c.h:47:1: error: template with C linkage template class _IncludeInsideExternCNotPortable; ^ In file included from include/c99_compat.h:28:0, from src/gallium/include/pipe/p_compiler.h:32, from src/gallium/auxiliary/util/u_math.h:42, from src/mesa/main/macros.h:35, from src/mesa/main/colormac.h:37, from src/mesa/drivers/haiku/swrast/SoftwareRast.cpp:28: include/no_extern_c.h:47:1: error: template with C linkage template class _IncludeInsideExternCNotPortable; Any alternative fix ideas besides me adding a if !defined(__HAIKU__) to include/no_extern_c.h? -- Alex ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH] include: Add helper header to help trap includes inside extern C.
Unfortunately, my build configuration does not build gallium. This caused me to miss some files which still have extern C includes. Due to this oversight, master encounters build errors. I'll send a patch asap. -Mark Mark Janes writes: > Assuming my patch to fix 'extern "C"' issues is pushed before this one, > > Reviewed-by: Mark Janes > > Jose Fonseca writes: > >> From: José Fonseca >> >> This is just to help repro and fixing these issues with any C++ compiler -- >> >> commiting this will of course wait until all issues are addressed. >> >> >> $ scons src/glsl/ >> scons: Reading SConscript files ... >> Checking for GCC ... yes >> Checking for Clang ... no >> Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes >> Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes >> Checking for XF86VIDMODE (xxf86vm)... yes >> Checking for DRM (libdrm >= 2.4.38)... yes >> Checking for UDEV (libudev >= 151)... yes >> warning: LLVM disabled: not building llvmpipe >> scons: done reading SConscript files. >> scons: Building targets ... >> scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl >> Compiling src/glsl/ast_array_index.cpp ... >> Compiling src/glsl/ast_expr.cpp ... >> Compiling src/glsl/ast_function.cpp ... >> Compiling src/glsl/ast_to_hir.cpp ... >> Compiling src/glsl/ast_type.cpp ... >> Compiling src/glsl/builtin_functions.cpp ... >> In file included from include/c99_compat.h:28:0, >> from src/mapi/u_compiler.h:4, >> from src/mapi/u_thread.h:47, >> from src/mapi/glapi/glapi.h:47, >> from src/mesa/main/mtypes.h:42, >> from src/mesa/main/errors.h:47, >> from src/mesa/main/imports.h:41, >> from src/mesa/main/core.h:44, >> from src/glsl/builtin_functions.cpp:58: >> include/no_extern_c.h:48:1: error: template with C linkage >> template class _IncludeInsideExternCNotPortable; >> ^ >> In file included from include/c99_compat.h:28:0, >> from include/c11/threads.h:38, >> from src/mapi/u_thread.h:49, >> from src/mapi/glapi/glapi.h:47, >> from src/mesa/main/mtypes.h:42, >> from src/mesa/main/errors.h:47, >> from src/mesa/main/imports.h:41, >> from src/mesa/main/core.h:44, >> from src/glsl/builtin_functions.cpp:58: >> include/no_extern_c.h:48:1: error: template with C linkage >> template class _IncludeInsideExternCNotPortable; >> ^ >> Compiling src/glsl/builtin_types.cpp ... >> Compiling src/glsl/builtin_variables.cpp ... >> scons: *** [build/linux-x86_64-debug/glsl/builtin_functions.os] Error 1 >> scons: building terminated because of errors. >> --- >> include/c99_compat.h | 2 ++ >> include/no_extern_c.h | 49 + >> src/util/u_atomic.h | 3 +++ >> 3 files changed, 54 insertions(+) >> create mode 100644 include/no_extern_c.h >> >> diff --git a/include/c99_compat.h b/include/c99_compat.h >> index 429c601..a8819ac 100644 >> --- a/include/c99_compat.h >> +++ b/include/c99_compat.h >> @@ -25,6 +25,8 @@ >> * >> **/ >> >> +#include "no_extern_c.h" >> + >> #ifndef _C99_COMPAT_H_ >> #define _C99_COMPAT_H_ >> >> diff --git a/include/no_extern_c.h b/include/no_extern_c.h >> new file mode 100644 >> index 000..d038a4f >> --- /dev/null >> +++ b/include/no_extern_c.h >> @@ -0,0 +1,49 @@ >> +/** >> + * >> + * Copyright 2014 VMware, Inc. >> + * All Rights Reserved. >> + * >> + * Permission is hereby granted, free of charge, to any person obtaining a >> + * copy of this software and associated documentation files (the >> "Software"), >> + * to deal in the Software without restriction, including without limitation >> + * the rights to use, copy, modify, merge, publish, distribute, sublicense, >> + * and/or sell copies of the Software, and to permit persons to whom the >> + * Software is furnished to do so, subject to the following conditions: >> + * >> + * The above copyright notice and this permission notice shall be included >> + * in all copies or substantial portions of the Software. >> + * >> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS >> + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF >> MERCHANTABILITY, >> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL >> + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR >> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, >> + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR >> + * OTHER DEALINGS IN THE SOFTWARE. >> + * >> + ***
Re: [Mesa-dev] [PATCH] include: Add helper header to help trap includes inside extern C.
Assuming my patch to fix 'extern "C"' issues is pushed before this one, Reviewed-by: Mark Janes Jose Fonseca writes: > From: José Fonseca > > This is just to help repro and fixing these issues with any C++ compiler -- > > commiting this will of course wait until all issues are addressed. > > > $ scons src/glsl/ > scons: Reading SConscript files ... > Checking for GCC ... yes > Checking for Clang ... no > Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes > Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes > Checking for XF86VIDMODE (xxf86vm)... yes > Checking for DRM (libdrm >= 2.4.38)... yes > Checking for UDEV (libudev >= 151)... yes > warning: LLVM disabled: not building llvmpipe > scons: done reading SConscript files. > scons: Building targets ... > scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl > Compiling src/glsl/ast_array_index.cpp ... > Compiling src/glsl/ast_expr.cpp ... > Compiling src/glsl/ast_function.cpp ... > Compiling src/glsl/ast_to_hir.cpp ... > Compiling src/glsl/ast_type.cpp ... > Compiling src/glsl/builtin_functions.cpp ... > In file included from include/c99_compat.h:28:0, > from src/mapi/u_compiler.h:4, > from src/mapi/u_thread.h:47, > from src/mapi/glapi/glapi.h:47, > from src/mesa/main/mtypes.h:42, > from src/mesa/main/errors.h:47, > from src/mesa/main/imports.h:41, > from src/mesa/main/core.h:44, > from src/glsl/builtin_functions.cpp:58: > include/no_extern_c.h:48:1: error: template with C linkage > template class _IncludeInsideExternCNotPortable; > ^ > In file included from include/c99_compat.h:28:0, > from include/c11/threads.h:38, > from src/mapi/u_thread.h:49, > from src/mapi/glapi/glapi.h:47, > from src/mesa/main/mtypes.h:42, > from src/mesa/main/errors.h:47, > from src/mesa/main/imports.h:41, > from src/mesa/main/core.h:44, > from src/glsl/builtin_functions.cpp:58: > include/no_extern_c.h:48:1: error: template with C linkage > template class _IncludeInsideExternCNotPortable; > ^ > Compiling src/glsl/builtin_types.cpp ... > Compiling src/glsl/builtin_variables.cpp ... > scons: *** [build/linux-x86_64-debug/glsl/builtin_functions.os] Error 1 > scons: building terminated because of errors. > --- > include/c99_compat.h | 2 ++ > include/no_extern_c.h | 49 + > src/util/u_atomic.h | 3 +++ > 3 files changed, 54 insertions(+) > create mode 100644 include/no_extern_c.h > > diff --git a/include/c99_compat.h b/include/c99_compat.h > index 429c601..a8819ac 100644 > --- a/include/c99_compat.h > +++ b/include/c99_compat.h > @@ -25,6 +25,8 @@ > * > **/ > > +#include "no_extern_c.h" > + > #ifndef _C99_COMPAT_H_ > #define _C99_COMPAT_H_ > > diff --git a/include/no_extern_c.h b/include/no_extern_c.h > new file mode 100644 > index 000..d038a4f > --- /dev/null > +++ b/include/no_extern_c.h > @@ -0,0 +1,49 @@ > +/** > + * > + * Copyright 2014 VMware, Inc. > + * All Rights Reserved. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included > + * in all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS > + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + **/ > + > + > +/* > + * Including system's headers inside `extern "C" { ... }` is not safe, as > system > + * headers may have C++ code in them, and C++ code inside extern "C" > + * leads to syntatically incorrect code. > + * > + * This is because putting code inside extern "C" won't make __cplusplus > define > + * go away, that is, the headers being inclu
Re: [Mesa-dev] [PATCH] include: Add helper header to help trap includes inside extern C.
Jose Fonseca writes: > From: José Fonseca > > This is just to help repro and fixing these issues with any C++ compiler -- > > commiting this will of course wait until all issues are addressed. Hi Jose, I have a patch which trivially fixes extern "C" in the 14 files identified by no_extern_c.h errors. Should I send the patch? This helper header was sent a long time ago, but it seems like a useful mechanism to me. -Mark > > > $ scons src/glsl/ > scons: Reading SConscript files ... > Checking for GCC ... yes > Checking for Clang ... no > Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes > Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes > Checking for XF86VIDMODE (xxf86vm)... yes > Checking for DRM (libdrm >= 2.4.38)... yes > Checking for UDEV (libudev >= 151)... yes > warning: LLVM disabled: not building llvmpipe > scons: done reading SConscript files. > scons: Building targets ... > scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl > Compiling src/glsl/ast_array_index.cpp ... > Compiling src/glsl/ast_expr.cpp ... > Compiling src/glsl/ast_function.cpp ... > Compiling src/glsl/ast_to_hir.cpp ... > Compiling src/glsl/ast_type.cpp ... > Compiling src/glsl/builtin_functions.cpp ... > In file included from include/c99_compat.h:28:0, > from src/mapi/u_compiler.h:4, > from src/mapi/u_thread.h:47, > from src/mapi/glapi/glapi.h:47, > from src/mesa/main/mtypes.h:42, > from src/mesa/main/errors.h:47, > from src/mesa/main/imports.h:41, > from src/mesa/main/core.h:44, > from src/glsl/builtin_functions.cpp:58: > include/no_extern_c.h:48:1: error: template with C linkage > template class _IncludeInsideExternCNotPortable; > ^ > In file included from include/c99_compat.h:28:0, > from include/c11/threads.h:38, > from src/mapi/u_thread.h:49, > from src/mapi/glapi/glapi.h:47, > from src/mesa/main/mtypes.h:42, > from src/mesa/main/errors.h:47, > from src/mesa/main/imports.h:41, > from src/mesa/main/core.h:44, > from src/glsl/builtin_functions.cpp:58: > include/no_extern_c.h:48:1: error: template with C linkage > template class _IncludeInsideExternCNotPortable; > ^ > Compiling src/glsl/builtin_types.cpp ... > Compiling src/glsl/builtin_variables.cpp ... > scons: *** [build/linux-x86_64-debug/glsl/builtin_functions.os] Error 1 > scons: building terminated because of errors. > --- > include/c99_compat.h | 2 ++ > include/no_extern_c.h | 49 + > src/util/u_atomic.h | 3 +++ > 3 files changed, 54 insertions(+) > create mode 100644 include/no_extern_c.h > > diff --git a/include/c99_compat.h b/include/c99_compat.h > index 429c601..a8819ac 100644 > --- a/include/c99_compat.h > +++ b/include/c99_compat.h > @@ -25,6 +25,8 @@ > * > **/ > > +#include "no_extern_c.h" > + > #ifndef _C99_COMPAT_H_ > #define _C99_COMPAT_H_ > > diff --git a/include/no_extern_c.h b/include/no_extern_c.h > new file mode 100644 > index 000..d038a4f > --- /dev/null > +++ b/include/no_extern_c.h > @@ -0,0 +1,49 @@ > +/** > + * > + * Copyright 2014 VMware, Inc. > + * All Rights Reserved. > + * > + * Permission is hereby granted, free of charge, to any person obtaining a > + * copy of this software and associated documentation files (the "Software"), > + * to deal in the Software without restriction, including without limitation > + * the rights to use, copy, modify, merge, publish, distribute, sublicense, > + * and/or sell copies of the Software, and to permit persons to whom the > + * Software is furnished to do so, subject to the following conditions: > + * > + * The above copyright notice and this permission notice shall be included > + * in all copies or substantial portions of the Software. > + * > + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS > + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF > MERCHANTABILITY, > + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL > + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR > + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, > + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR > + * OTHER DEALINGS IN THE SOFTWARE. > + * > + **/ > + > + > +/* > + * Including system's headers inside `extern "C" { ... }` is not safe, as > system > + * headers may have C++ code in them, and C++ code inside extern "C" > + * leads to syntatically incorrect code. > +
[Mesa-dev] [PATCH] include: Add helper header to help trap includes inside extern C.
From: José Fonseca This is just to help repro and fixing these issues with any C++ compiler -- commiting this will of course wait until all issues are addressed. $ scons src/glsl/ scons: Reading SConscript files ... Checking for GCC ... yes Checking for Clang ... no Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes Checking for XF86VIDMODE (xxf86vm)... yes Checking for DRM (libdrm >= 2.4.38)... yes Checking for UDEV (libudev >= 151)... yes warning: LLVM disabled: not building llvmpipe scons: done reading SConscript files. scons: Building targets ... scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl Compiling src/glsl/ast_array_index.cpp ... Compiling src/glsl/ast_expr.cpp ... Compiling src/glsl/ast_function.cpp ... Compiling src/glsl/ast_to_hir.cpp ... Compiling src/glsl/ast_type.cpp ... Compiling src/glsl/builtin_functions.cpp ... In file included from include/c99_compat.h:28:0, from src/mapi/u_compiler.h:4, from src/mapi/u_thread.h:47, from src/mapi/glapi/glapi.h:47, from src/mesa/main/mtypes.h:42, from src/mesa/main/errors.h:47, from src/mesa/main/imports.h:41, from src/mesa/main/core.h:44, from src/glsl/builtin_functions.cpp:58: include/no_extern_c.h:48:1: error: template with C linkage template class _IncludeInsideExternCNotPortable; ^ In file included from include/c99_compat.h:28:0, from include/c11/threads.h:38, from src/mapi/u_thread.h:49, from src/mapi/glapi/glapi.h:47, from src/mesa/main/mtypes.h:42, from src/mesa/main/errors.h:47, from src/mesa/main/imports.h:41, from src/mesa/main/core.h:44, from src/glsl/builtin_functions.cpp:58: include/no_extern_c.h:48:1: error: template with C linkage template class _IncludeInsideExternCNotPortable; ^ Compiling src/glsl/builtin_types.cpp ... Compiling src/glsl/builtin_variables.cpp ... scons: *** [build/linux-x86_64-debug/glsl/builtin_functions.os] Error 1 scons: building terminated because of errors. --- include/c99_compat.h | 2 ++ include/no_extern_c.h | 49 + src/util/u_atomic.h | 3 +++ 3 files changed, 54 insertions(+) create mode 100644 include/no_extern_c.h diff --git a/include/c99_compat.h b/include/c99_compat.h index 429c601..a8819ac 100644 --- a/include/c99_compat.h +++ b/include/c99_compat.h @@ -25,6 +25,8 @@ * **/ +#include "no_extern_c.h" + #ifndef _C99_COMPAT_H_ #define _C99_COMPAT_H_ diff --git a/include/no_extern_c.h b/include/no_extern_c.h new file mode 100644 index 000..d038a4f --- /dev/null +++ b/include/no_extern_c.h @@ -0,0 +1,49 @@ +/** + * + * Copyright 2014 VMware, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + * + **/ + + +/* + * Including system's headers inside `extern "C" { ... }` is not safe, as system + * headers may have C++ code in them, and C++ code inside extern "C" + * leads to syntatically incorrect code. + * + * This is because putting code inside extern "C" won't make __cplusplus define + * go away, that is, the headers being included thinks is free to use C++ as it + * sees fits. + * + * Including non-system headers inside extern "C" is not safe either, because + * non-system headers end up including system headers, hence fall in the above + * case too. + * + * Conclusion, includes inside extern "C" is simply not portable. + * + * + * This header helps surface this issues. +