Alien-TinyCCx
view release on metacpan or search on metacpan
src/tests/tcctest.c view on Meta::CPAN
printf("__LINE__=%d __FILE__=%s\n",
__LINE__, __FILE__);
#line 203 "test"
printf("__LINE__=%d __FILE__=%s\n",
__LINE__, __FILE__);
#line 227 "tcctest.c"
#endif
/* not strictly preprocessor, but we test it there */
#ifdef C99_MACROS
printf("__func__ = %s\n", __func__);
dprintf(1, "vaarg=%d\n", 1);
#endif
dprintf1(1, "vaarg1\n");
dprintf1(1, "vaarg1=%d\n", 2);
dprintf1(1, "vaarg1=%d %d\n", 1, 2);
/* gcc extension */
printf("func='%s'\n", __FUNCTION__);
/* complicated macros in glibc */
printf("INT64_MIN=" LONG_LONG_FORMAT "\n", INT64_MIN);
{
int a;
a = 1;
glue(a+, +);
printf("a=%d\n", a);
glue(a <, <= 2);
printf("a=%d\n", a);
}
/* macro function with argument outside the macro string */
#define MF_s MF_hello
#define MF_hello(msg) printf("%s\n",msg)
#define MF_t printf("tralala\n"); MF_hello
MF_s("hi");
MF_t("hi");
/* test macro substituion inside args (should not eat stream) */
printf("qq=%d\n", qq(qq)(2));
/* test zero argument case. NOTE: gcc 2.95.x does not accept a
null argument without a space. gcc 3.2 fixes that. */
#define qq1(x) 1
printf("qq1=%d\n", qq1( ));
/* comment with stray handling *\
/
/* this is a valid *\/ comment */
/* this is a valid comment *\*/
// this is a valid\
comment
/* test function macro substitution when the function name is
substituted */
TEST2();
/* And again when the name and parenthes are separated by a
comment. */
TEST2 /* the comment */ ();
}
static void print_num(char *fn, int line, int num) {
printf("fn %s, line %d, num %d\n", fn, line, num);
}
void recursive_macro_test(void)
{
#define ELF32_ST_TYPE(val) ((val) & 0xf)
#define ELF32_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
#define STB_WEAK 2 /* Weak symbol */
#define ELFW(type) ELF##32##_##type
printf("%d\n", ELFW(ST_INFO)(STB_WEAK, ELFW(ST_TYPE)(123)));
#define WRAP(x) x
#define print_num(x) print_num(__FILE__,__LINE__,x)
print_num(123);
WRAP(print_num(123));
WRAP(WRAP(print_num(123)));
static struct recursive_macro { int rm_field; } G;
#define rm_field (G.rm_field)
printf("rm_field = %d\n", rm_field);
printf("rm_field = %d\n", WRAP(rm_field));
WRAP((printf("rm_field = %d %d\n", rm_field, WRAP(rm_field))));
}
int op(a,b)
{
return a / b;
}
int ret(a)
{
if (a == 2)
return 1;
if (a == 3)
return 2;
return 0;
}
void ps(const char *s)
{
int c;
while (1) {
c = *s;
if (c == 0)
break;
printf("%c", c);
s++;
}
}
const char foo1_string[] = "\
bar\n\
( run in 0.586 second using v1.01-cache-2.11-cpan-e1769b4cff6 )