[ create a new paste ] login | about

Link: http://codepad.org/WOZ14V9e    [ raw code | output | fork ]

AaronMiller - C++, pasted on Oct 3:
#include <cstdio>
#include <cstdarg>

inline void debugf_int(const char *file, unsigned int line, const char *fmt, ...) {
  static char buf[8192];
  va_list args;

  va_start(args, fmt);
  vsnprintf(buf, sizeof(buf)-1, fmt, args);
  buf[sizeof(buf)-1] = 0;
  va_end(args);

  fprintf(stderr, "debug: %s:%u: %s\n", file, line, buf);
  fflush(stderr);
}

inline void get_xy(int *x, int *y) { *x=4; *y=2; }

extern "C" {

#define debugf(f,...) debugf_int(__FILE__, __LINE__, f, ##__VA_ARGS__)
#define get_x() ({int T_x,T_y;get_xy(&T_x,&T_y);T_x;})
#define get_y() ({int T_x,T_y;get_xy(&T_x,&T_y);T_y;})

int main() {
  debugf("Hello, world! %d,%d", get_x(), get_y());
  return 0;
}

}


Output:
1
2
3
In function 'int main()':
Line 26: error: ISO C++ forbids braced-groups within expressions
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: