results in the same expansion as the first three lines.
Ultimately, this new_macro would then be joined with the prtmem macro so that prtmem(x) will print the string stored in PROGMEM. And please don't suggest using the F() macro as this is intended to replace it, using only GCC compiler functions. The issue involves stringifying the x parameter from prtmem(x) through all the subsequent macro calls.
No. That bit's easy. The tough part is in doing the macros. The whole point of the exercise is to have it embedded in the code as external libraries are not permitted. The concept of monolithic code is to remove dependencies on third party libraries and use only what gets distributed with the compiler. Also, C only, no C++ templates, etc.
IIRC, the only thing wrong with it is that PSTR(“FOO”) is the same type as “FOO”, so you can’t overload a function to handle both ram strings and flash string...
I've tried playing with PSTR but must confess that I haven't as yet got working syntax. I bailed and asked for help. Still working on it. When I get the solution I will post.
Don't you have extra braces in there? I don't know whether that's a problem.
I don't think that you'll be able to have a single macro that can used with both string literals (like PROGMEM) AND variable initializations (like F() or PSTR()) That's true in the C++/Arduino world as well.
This sketch produces:
test text
Sketch uses 1508 bytes (4%) of program storage space.
hello
HELPME
foo, test1, test2, and buf, are all in flash.
That sort-of looks like what you asked for, but It's not a replacement for F(), which you also asked for...
Thanks for that. It may be as close as I get. It's not so much a replacement for F() as it is an abstraction of the PROGMEM write/read process. Having a few unused pre-processor directives hanging around, if needed, as opposed to referring to the library manual for syntax when you do want it. Cheers. K+.