The static class member static_member
not recognised in the following code.
However, it works on older versions of the compiler. The compiler I use is based on clang
.
class my_class {
public:
static int static_member;
};
int main() {
my_class::static_member = 0;
}
To reproduce the error, save above file as c1.cpp
and run:
VER_TAG=latest # or VER_TAG=3.1.8
docker run --rm -v $(pwd):/src emscripten/emsdk::$VER_TAG emcc /src/c1.cpp
Leads to error:
wasm-ld: error: /tmp/emscripten_temp_o3wmmq8k/c1_0.o: undefined symbol: my_class::static_member
However, if I use
VER_TAG=2.0.22
(earlier release of the compiler), it works fine.
Is there anything wrong with my code? Or is it related to compiler implementation?