0

I got this small code I'm trying things on for like an hour.

int receivers = 0;
#if defined(PPM_RECEIVER)
  receivers++;
#endif

And I just cannot get it working, It keeps returning a "'receivers' does not name a type" on line 4.

2
  • 2
    Question about C/C++ syntax. This is counted as off topic on Arduino SE.
    – MichaelT
    Commented May 16, 2019 at 20:20
  • Maybe you mistyped receivers; did you copy-paste the code here or rewrote it? Of course then this code is written inside a function, isn't it?
    – frarugi87
    Commented May 21, 2019 at 6:52

1 Answer 1

3

You can't use commands like receivers++ outside of a function. That is runtime executable code, and has to be run from inside a function. Global scope doesn't get executed in the same way as code in a function.

1
  • Ah that makes sense, Thank you!
    – user56727
    Commented May 16, 2019 at 17:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.