Help understanding this Macro

A

Affan Syed

Hi,
I have done a lot of user space coding in C, which doesnt really need me to
understand the following MACRO:

#define UARTOutput(__x,__y,__args...) do { \
static char __s[] PROGMEM = __y; \
if (debug_out) \
printf_P(__s, ## __args); \
} while (0)

So now what exactly is happening over here?
Does double underscore do something special? Basically i can see that it is
used as outputting a string to the UART like this
UARTOutput(DBG,"%s", buf);

So it just outputs the string in buf to the UART... but how (Assume that the
UART is somehow initialized.. how is it even going to the UART!!!

Thanks..
Affan
 
J

Jogi Kuenstner

Affan said:
[...]
So it just outputs the string in buf to the UART... but how (Assume that
the UART is somehow initialized.. how is it even going to the UART!!!

Through the function printf_P ?
The only solution I can imagine...

Jogi
 
W

Walter Roberson

:I have done a lot of user space coding in C, which doesnt really need me to
:understand the following MACRO:

: #define UARTOutput(__x,__y,__args...) do { \
: static char __s[] PROGMEM = __y; \
: if (debug_out) \
: printf_P(__s, ## __args); \
: } while (0)

:So now what exactly is happening over here?

We can't tell -- you haven't told us anything about printf_P(), which
is not a standard C routine.

:Does double underscore do something special?

The standard reserves __ followed by an upper-case letter
for future and implimentation enhancements, but otherwise NO.

:So it just outputs the string in buf to the UART... but how

printf_P is sending it there.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top