linker error C++

Technical questions regarding the XTC tools and programming with XMOS.
User avatar
fabriceo
Respected Member
Posts: 280
Joined: Mon Jan 08, 2018 4:14 pm

linker error C++

Post by fabriceo »

Hello
I get a warning by the linker when using static variables in a c++ class:
dsp_app.cpp: Warning: Undefined reference to '_ZN7Counter5countE'

Code: Select all

class Counter { 
public:
    static unsigned count;
    Counter() { count++; }
};

void test() {
    Counter c;
    debug_printf("count %d\n", c.count );
}
FYI, I have added -std=c+11 in the XCC_FLAGS. using XTC15.3.1
this is not a template class requiring some specialisation
any suggestion ??
Thank you !
fabriceo