|
|
|
## Trazas de depuración
|
|
|
|
|
|
|
|
Normalmente, durante el desarrollo de las prácticas necesitas generar trazas de depuración para comprobar el correcto funcionamiento de la misma. Esas trazas no deben salir cuando entregues la práctica. Para evitar comentar o modificar código innecesariamente puedes utilizar la siguiente macro.
|
|
|
|
|
|
|
|
```c
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define DEBUG_PRINTF(...) printf("DEBUG: "__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define DEBUG_PRINTF(...)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char **args) {
|
|
|
|
|
|
|
|
char* msg = "world!";
|
|
|
|
DEBUG_PRINTF("hello %s\n", msg);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
Utiliza la macro _DEBUG_PRINTF_ para imprimir todos tus mensajes de depuración. Solo se imprimirán si al compilar utilizas el flag _-DDEBUG_. De lo contrario, no se mostrarán. |
|
|
|
\ No newline at end of file |