fork download
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <strings.h> //bzero
  4. #include <stdlib.h>
  5.  
  6. #define alloca malloc // no alloca in the standard
  7. #define DEBUG_STREAM stderr
  8. #define BUFFER_SIZE_DEBUG 500
  9.  
  10. #define EVALUATE_TYPE(x) 1
  11.  
  12. #define _DEBUG_ADD(string, ...) \
  13. do{ \
  14. if (EVALUATE_TYPE(string)){ \
  15. size_t size = strlen(string) + BUFFER_SIZE_DEBUG; \
  16. char *buffer = alloca(size); \
  17. bzero(buffer, size); \
  18. snprintf(buffer, size, string, __VA_ARGS__); \
  19. fwrite(buffer, strlen(buffer), 1, DEBUG_STREAM); }} \
  20. while(0)
  21.  
  22.  
  23.  
  24. int main(void) {
  25. _DEBUG_ADD("%d %d %d\n", 1, 2, 3);
  26. }
  27.  
Success #stdin #stdout #stderr 0s 9424KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
1 2 3