c_programming_language/c_modern_approach/Preprocessor/ellipsis.c

11 lines
422 B
C

#include <stdio.h>
#define TEST(condition, ...) \
((condition) ? printf("Passed test: %s\n", #condition) : printf(__VA_ARGS__))
int main() {
int voltage = 30;
int max_voltage = 20;
TEST(voltage <= max_voltage, "Voltage %d exceeds %d\n", voltage, max_voltage);
max_voltage = 40;
TEST(voltage <= max_voltage, "Voltage %d exceeds %d\n", voltage, max_voltage);
}