Skip to content
This repository has been archived by the owner on Aug 1, 2024. It is now read-only.

config/platform/avr.hpp undefs F() macro #4

Open
pnd10 opened this issue Sep 27, 2016 · 1 comment
Open

config/platform/avr.hpp undefs F() macro #4

pnd10 opened this issue Sep 27, 2016 · 1 comment

Comments

@pnd10
Copy link

pnd10 commented Sep 27, 2016

In the Arduino WString.h header, the F() macro is defined to allow strings to be put in flash (saving precious SRAM).

At the end of boost/config/platform/avr.hpp is the following snippet:

// Defined by arduino/wiring WString.h
#ifdef F
  #undef F
#endif

This means that the F() macro no longer works, and produces compilation errors:
error: ‘F’ was not declared in this scope
What is the reason for undefining the macro? At the very least, the explicit reason why F() is undefined should be documented, and what to do about it if you need to use the F() macro

@matthijskooijman
Copy link

I assume the reason is that boost uses F as an identifier (e.g. variable name or template argument) in a ton of places, so keeping it defined will break parsing of all those places. It's a bit annoying that Arduino uses such a short macro, but we'll have to deal with it anyway. One alternative to undeffing the macro is to use the push_macro and pop_macro pragmas, though I'm not sure how portable or future-proof that is (gcc documents "For compatibility with Microsoft Windows compilers, GCC supports ‘#pragma push_macro("macro_name")’"

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants