I have larger C code base, where I want to integrate some C++ code. The C++ code needs some declarations from the C code base.
Compiler is currently GCC 6.3.1, but we might be able to update the compiler.
Basically, the included C headers contain code like this:
#define NRF_GPIO ((int*) 0x0000112233)
static_assert(NRF_GPIO == NRF_GPIO, "asd");
This compiles fine, if the compiler compiles C files, but fails, if the code is written in C++, as the reinterpret cast will not yield in a constant expression and the compiler correctly complains about it:
error: non-constant condition for static assertion
static_assert(NRF_GPIO == NRF_GPIO, "asd");
^
t.cpp:2:20: error: reinterpret_cast from integer to pointer
#define NRF_GPIO ((int*) 0x0000112233)
~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
t.cpp:3:15: note: in expansion of macro 'NRF_GPIO'
static_assert(NRF_GPIO == NRF_GPIO, "asd");
Is there a way to let the GCC compile the C++ a little bit more relaxed and thus to except the code above?
#define NRF_GPIO_ADDR 0x0000112233and#define NRF_GPIO ((int*) NRF_GPIO_ADDR)and useNRF_GPIO_ADDRfor the assertion?#ifndef __cplusplusto make it a C/C++ header)static_assert.