31 lines
1003 B
C
31 lines
1003 B
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
// TODO: Change the debug macro to behave like printf when -DDebug is set
|
|
// And to do nothing if not;
|
|
#define debug(String, ...)
|
|
// The three dots mean, you can pass as many or as little arguments as you want
|
|
// to access these arguments use __VA_ARGS__
|
|
|
|
// a macro for simple error output with some extra debug info
|
|
#define ERROR(Text) printf("ERROR: File: %s Function: %s Line: %d. %s\n", __FILE__, __func__, __LINE__, Text)
|
|
// TODO: wrap this macro as well
|
|
|
|
int main(int argc, const char *argv[])
|
|
{
|
|
// Sometimes you just want to print stuff when debugging
|
|
// and it is tedious to constantly remove them just to add then later again
|
|
int foo = 42;
|
|
debug("%d\n", foo);
|
|
|
|
// Maybe you want to use the preprocessor to log errors.
|
|
// It could be useful to print out some information like the
|
|
// line number, filename and function name
|
|
|
|
if(foo != 30)
|
|
{
|
|
// Logging the Error
|
|
ERROR("Something went wrong!");
|
|
}
|
|
}
|