initialization sequence of static objects

I want to restrict the initialization sequence of static objects. So I apply the __attribute init_priority of g++ to achieve it. I want the static object
Sensor Sensor::sensor __attribute__((init_priority(2)));

initialized before an array of object
Motor Motor::motors[4] __attribute__((init_priority(3))) = {Motor(D28),Motor(D27),Motor(D11),Motor(D12)};

. Will the temporary objects be initialized after sensor object? Thanks in advance.
Last edited on
I would read the gcc/g++ documentation to find out.

[edit 1] According to it should work as you expect.

[edit 2] except that your numbers 2 and 3 are wrong; the numbers have to be within 101 and 65535 inclusive (I'm guessing the first 100 are reserved).
Last edited on
Topic archived. No new replies allowed.