[ create a new paste ] login | about

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

C, pasted on Mar 8:
#include <stdio.h>
#include <unistd.h>
#include <time.h>

#define DEBUG_PRINT1(f, x) do {\
    char buf[20]; struct tm tm_; time_t t = time(0); \
    localtime_r(&t, &tm_); \
    strftime(buf, sizeof buf, "%Y-%m-%dT%T", &tm_);\
    fprintf(stderr, "%s [%s:" __FILE__ ":%d] " f "\n", buf, __func__, __LINE__, (x));\
} while (0)
#define D(x) DEBUG_PRINT1("%s", (x))
#define DD(f, x) DEBUG_PRINT1(#x " == " f, (x))
#define DX(x) do { D(#x); (x); } while (0)

int main(void)
{
    D("test");

    const char * str = "hogehoge";
    D(str);

    DX(puts("hoge"));

    int a = 500;
    DD("%d", a - 1);

    return 0;
}


Output:
1
2
3
4
5
6
2008-03-08T13:42:47 [main:t.c:18] test
2008-03-08T13:42:47 [main:t.c:21] hogehoge
2008-03-08T13:42:47 [main:t.c:23] puts("hoge")
2008-03-08T13:42:47 [main:t.c:26] a - 1 == 499
hoge



Create a new paste based on this one


Comments: