#include <stdio.h>
#define BEGIN_FUNC(name, inm, outm) \
typedef struct name##_in_t { inm } name##_in; \
typedef struct name##_out_t { outm } name##_out; \
name##_out name(name##_in *in) {name##_out out; printf("l%d %d\n", sizeof(name##_in), sizeof(name##_out));
#define END_FUNC return out;}
#define CALL(output, name, invar ... ) output = name(&(name##_in){invar})
#define CALLA(output, name, invar ... ) name##_out output = name(&(name##_in){invar})
BEGIN_FUNC(test, int a; int ab;, int b;)
printf("%d %d\n", in->a, in->ab);
out.b = in->a * 2;
END_FUNC
int main(void)
{
int x = 2;
CALLA(outpt, test, 20, x);
printf("%d\n", outpt.b);
CALL(outpt, test, 30);
printf("%d\n", outpt.b);
return 0;
}
Thursday, December 10, 2009
Some crazy macro-abuse I came up with..
... not terribly useful in and of itself, but it allows for an organized extensible systemcall-y/pseudo-dynamic library setup.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment