This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

C++ Constructor is not called

Hi.

Im new to ncs and zephyr but I've got lot of expirience in embedded software.

Today I add a class and a global instance of this class.

So I expected that the constructor is called before main().

But the constructor is never called.

Is there a solution for C++?

class C
{
public:
 C(void)
 {
   m = 5;
 }
 int Get(void)
 {
  m++;
  return m;
 }

private:
 int m;
};

C c;

void main(void)
{

 printk("C::m %d\n", c.Get());

}

Related