Is it possible to determine at runtime whether a pointer points to PROGMEM'ed values or regular values? This would give some flexibility when writing code that handles both.


Not really, if you are asking whether you can determine (simply from its value) whether 0x100 is in RAM or PROGMEM. Both are possible candidates for a memory location.

The F() macro works around this by changing the type of a variable at compile-time, so that the compiler can select a suitable method of printing. For example:

Serial.println ("Hello, world");
Serial.println (F("Hello, world"));

In this case the appropriate println function is chosen at compile-time by the compiler, based on the type (one would be a const char *, the other a __FlashStringHelper type).

You are best off designing a way (similar to the F() macro) where you can make the decision at compile time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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