Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int num_instances;
- struct A
- {
- A()
- {
- order = ++num_instances;
- }
- int order;
- };
- A a3;
- A a2 __attribute__((init_priority(1000)));
- A a1 __attribute__((init_priority(990)));
- void setup()
- {
- Serial.begin(115200);
- }
- void loop()
- {
- int errors = 0;
- if (a1.order != 1) {
- Serial.print(F("Bad a1 order "));
- Serial.println(a1.order); // This must output 1
- ++errors;
- }
- if (a2.order != 2) {
- Serial.print(F("Bad a2 order "));
- Serial.println(a2.order); // This must output 2
- ++errors;
- }
- if (a3.order != 3) {
- Serial.print(F("Bad a3 order "));
- Serial.println(a3.order); // This must output 3
- ++errors;
- }
- if (!errors)
- Serial.println(F("Okay!"));
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement