Chris--A / PrintEx

An extension to the Arduino Print library, and much, much more...
GNU General Public License v3.0
61 stars 16 forks source link

develop branch - support for printf with no parameters #31

Open GiovanniCmpaner opened 5 years ago

GiovanniCmpaner commented 5 years ago

I'm trying to use printf with empty parameters, like:

printf("Just a debug string")

Currently, I get a compiler error with the original code.

The solution is to change these lines: https://github.com/Chris--A/PrintEx/blob/7e13cfc1998920262e1f575def2c146ac8958523/src/lib/PrintExtension.h#L202-L203 https://github.com/Chris--A/PrintEx/blob/7e13cfc1998920262e1f575def2c146ac8958523/src/lib/PrintExtension.h#L208

To:

#define sprintf(buff, str, ...) GString(buff).printf(str, ##__VA_ARGS__)
#define xprintf(out, str, ...) PrintEx(out).PRINTF_ALIAS(str, ##__VA_ARGS__)
#define printf(format, ...) PRINTF_ALIAS(format, ##__VA_ARGS__)

Note the leading ## in __VA_ARGS__

scottchiefbaker commented 5 years ago

What is the status of this issue. Seems like something that should get fixed for sure.