Hello,
My macro looks like this:
Code:
#include <stdio.h>
#include <stdbool.h>
#define PRINT_ONCE(message) \
do { \
static bool fixme_written = 0;\
if (!fixme_written) \
{\
fixme_written = 1; \
fprintf(stderr, message); \
} \
} while (0)
static void OnlyPrintOnce()
{
PRINT_ONCE("This patch is broken\n");
}
int main()
{
int i;
for (int i = 0; i < 10; i++)
{
OnlyPrintOnce();
}
}
Seeing as prinft takes variable number of arguments, it is not clear to me how to pass such arguments from the macro. Could anyone give me a heads up on how this could be done? It is probably simple but has eluded me so far so good.
Thanks in advance.