-
Notifications
You must be signed in to change notification settings - Fork 1k
Overly-generic defines in utils.h break some compilations #389
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Those can be used at sketch level, that's why |
That would only help to some degree, but even in uppercase the name is very generic and chances of collision remain. Uppercasing would reduce the chance of collision, but it is still likely that a sketch will define a
They can be used, but should they? Are they actually part of the core STM32 core API? Are they documented anywhere? The official Arduino cores do not provide them AFAIK, so this would be an STM32-specific addition. Also, I would expect that anyone toying with macros that need this macro, could just as well add these macros themselves. Portable sketches (that run on non-STM32-cores) will have to do so anyway, and if the availability of this macro is not documented (and thus not guaranteed to remain in future version), I would personally not want to rely on it and implement my own version anyway.
That does seem useful, as that seems to be part of the official Arduino API (or at least the de facto standard). But that is of course a matter of including |
More than one year this is included without any complains so I guess this is not really used at user sketch. This is only provide for convenience.
Probably not as I'm late in writing the doc :( |
Include utils.h manually will provide them Note: str() and xstr() are now capitalized. Fix stm32duino#389 Signed-off-by: Frederic.Pillon <[email protected]>
To avoid any name conflict xstr macro was capitalized and required to include header file manually. See stm32duino/Arduino_Core_STM32#389 Signed-off-by: Frederic.Pillon <[email protected]>
Include utils.h manually will provide them Note: str() and xstr() are now capitalized. Fix stm32duino#389 Signed-off-by: Frederic.Pillon <[email protected]>
This core contains a few very generic defines in utils.h:
Arduino_Core_STM32/cores/arduino/utils.h
Lines 6 to 13 in fa0dcc8
Especially the
str
andxstr
defines are problematic, since you might be using those as function or method names, which triggers the preprocessor. I ran into this issue when using the boost library, which has astr
method somewhere, but this can be easily reproduced with this sketch:Which gives:
Here, it points to the problematic macro, but in my original problem case the second message was not present, making this particularly tricky to diagnose.
As for resolving this:
str()
andxstr()
macros are not actually used in the entire core, so I suggest removing them.CONCAT
andCONCATS
macros could perhaps be rename as well, but better would be to not expose them from header files. grep shows that these macros are only used in .c files, so simply includingutils.h
from those .c files, and dropping the include fromwiring.h
sounds like the best approach to me.The text was updated successfully, but these errors were encountered: