icp/oer/courses/c-basics/sections/17-preprocessor/02-debug/solution.c

29 lines
458 B
C

#include <stdio.h>
#include <stdlib.h>
#ifdef DEBUG
#define debug(String, ...) printf(String, __VA_ARGS__)
#define ERROR(Text) printf("ERROR: File: %s Function: %s Line: %d. %s\n", __FILE__, __func__, __LINE__, Text)
#else
#define debug(String, ...)
#define ERROR(Text)
#endif
int main(int argc, const char *argv[])
{
int foo = 42;
debug("%d\n", foo);
if(foo != 30)
{
// Logging the Error
ERROR("Something went wrong!");
}
}