I would like to initialize a constexpr variable with another variable, made visible by extern:
test.cpp
#include "test.h"
int const a[] = {1};
int const d = 4;
test.h
extern int const a[];
extern int const d;
main.cpp
#include "test.h"
int main(void) {
constexpr const int * b = a;
constexpr const int e = d;
}
(Only) The second line in main gives the following error:
error: the value of 'd' is not usable in a constant expression
and
test.h:3:18: note: 'd' was not initialized with a constant expression
Could somebody help me to understand, why only one of the two examples fails?