Skip to main content

Practice ยท 3 of 4

Variadic Log with __VA_OPT__

CHALLENGE
Difficulty: advanced+25 XP

Implement const char *last_log(void) plus a macro LOG(fmt, ...) that appends into a static buffer (snprintf, appended at an offset) and returns the accumulated text. Calls like LOG("a=%d", 7) and LOG("bare") must both compile and both be retrievable โ€” the __VA_OPT__ comma handling is the point.

Back to lesson: Practice: Preprocessor Mechanics Drills