Change const to constexpr
static const within a class is somewhat broken in a variety of contexts
in C++. In particular, you should not try to define the value at the
declaration site, like:
class MyClass {
public:
static const int mConst = 5;
};
For some reason, C++ allows this, but then you can only use mConst in
integral constant expressions. If you need a reference, then this whole
thing breaks. However, under certain compilation options, the compiler
may compile away the references and it will compile anyway (which seems
to be the status quo for this particular case).
Anyway, I have been fiddling with the compiler options, and I now get an
undefined references for the constants in this file. Because we don't
actually need a concrete object in memory for these values, static
constexpr should be a much better option for such a constant.
Reference: https://stackoverflow.com/a/3026054
Flag: EXEMPT bugfix
Change-Id: I054063040f822ac86ae73d8ab59603474bb52586
Loading
Please register or sign in to comment