You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A sketch with this line here #define s1 42
doesn't compile because it breaks the prototype at avr/include/string.h:129 extern char *strdup(const char *s1);
.
I don't use Arduino but I think s1 is not supposed to be a reserved identifier.
My suggestion would be using __s1 or_S1. I am not familiar enough with the app to suggest (let alone commit) a different order of processing the Arduino sketch to C++.
The text was updated successfully, but these errors were encountered:
a3f
changed the title
User #define's clashing with automatically added headers
User #define clashes with automatically added headers
Sep 7, 2014
This is a problem with macros - if you use them you should use sufficiently long identifiers to prevent conflicts. Alternatively, you can use constants, which are properly parsed and scoped by the compiler, so are less powerful, bug also more reliable:
I beg to differ. That's not a problem with macros, but with the fact that the macros are inserted before the automatically added headers, which is something caused by Arduino.
This might be useful for #define'ing NDEBUG when using assertions for example but that doesn't justify breaking conformant code.
As for the fixable part using __s1 or _S1 should do the trick, as they are reserved for implementation use anyway.
A sketch with this line here
#define s1 42
doesn't compile because it breaks the prototype at avr/include/string.h:129
extern char *strdup(const char *s1);
.
I don't use Arduino but I think
s1
is not supposed to be a reserved identifier.My suggestion would be using
__s1
or_S1
. I am not familiar enough with the app to suggest (let alone commit) a different order of processing the Arduino sketch to C++.The text was updated successfully, but these errors were encountered: