Sep 8, 2012 at 1:43am UTC
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 Sep 8, 2012 at 1:44am UTC
Sep 9, 2012 at 2:58am UTC
I would read the gcc/g++ documentation to find out.
[edit 1] According to
http://gcc.gnu.org/onlinedocs/gcc/C_002b_002b-Attributes.html 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 Sep 9, 2012 at 3:00am UTC