The code below does not compile neither in gcc
nor in clang
. Both complain that, the reinterpret_cast
to int*
is not a constexpr
.
How can I work-around the problem? Note that I cannot modify the macro PORT
, as it is defined in a 3-rd party library (avr
).
#include <iostream>
#define PORT ((int *)(0x20))
constexpr int *p = PORT; // does not compile
int main() {
std::cout << (uintptr_t) p << "\n";
return 0;
}