Alien-TinyCC
view release on metacpan or search on metacpan
src/tcc-doc.texi view on Meta::CPAN
printf("unexpected\n");
break;
@}
@end example
@cindex aligned attribute
@cindex packed attribute
@cindex section attribute
@cindex unused attribute
@cindex cdecl attribute
@cindex stdcall attribute
@cindex regparm attribute
@cindex dllexport attribute
@item The keyword @code{__attribute__} is handled to specify variable or
function attributes. The following attributes are supported:
@itemize
@item @code{aligned(n)}: align a variable or a structure field to n bytes
(must be a power of two).
@item @code{packed}: force alignment of a variable or a structure field to
1.
@item @code{section(name)}: generate function or data in assembly section
name (name is a string containing the section name) instead of the default
section.
@item @code{unused}: specify that the variable or the function is unused.
@item @code{cdecl}: use standard C calling convention (default).
@item @code{stdcall}: use Pascal-like calling convention.
@item @code{regparm(n)}: use fast i386 calling convention. @var{n} must be
between 1 and 3. The first @var{n} function parameters are respectively put in
registers @code{%eax}, @code{%edx} and @code{%ecx}.
@item @code{dllexport}: export function from dll/executable (win32 only)
@end itemize
Here are some examples:
@example
int a __attribute__ ((aligned(8), section(".mysection")));
@end example
@noindent
align variable @code{a} to 8 bytes and put it in section @code{.mysection}.
@example
int my_add(int a, int b) __attribute__ ((section(".mycodesection")))
@{
return a + b;
@}
@end example
@noindent
generate function @code{my_add} in section @code{.mycodesection}.
@item GNU style variadic macros:
@example
#define dprintf(fmt, args@dots{}) printf(fmt, ## args)
dprintf("no arg\n");
dprintf("one arg %d\n", 1);
@end example
@item @code{__FUNCTION__} is interpreted as C99 @code{__func__}
(so it has not exactly the same semantics as string literal GNUC
where it is a string literal).
@item The @code{__alignof__} keyword can be used as @code{sizeof}
to get the alignment of a type or an expression.
@item The @code{typeof(x)} returns the type of @code{x}.
@code{x} is an expression or a type.
@item Computed gotos: @code{&&label} returns a pointer of type
@code{void *} on the goto label @code{label}. @code{goto *expr} can be
used to jump on the pointer resulting from @code{expr}.
@item Inline assembly with asm instruction:
@cindex inline assembly
@cindex assembly, inline
@cindex __asm__
@example
static inline void * my_memcpy(void * to, const void * from, size_t n)
@{
int d0, d1, d2;
__asm__ __volatile__(
"rep ; movsl\n\t"
"testb $2,%b4\n\t"
"je 1f\n\t"
"movsw\n"
"1:\ttestb $1,%b4\n\t"
"je 2f\n\t"
"movsb\n"
"2:"
: "=&c" (d0), "=&D" (d1), "=&S" (d2)
:"0" (n/4), "q" (n),"1" ((long) to),"2" ((long) from)
: "memory");
return (to);
@}
@end example
@noindent
@cindex gas
TCC includes its own x86 inline assembler with a @code{gas}-like (GNU
assembler) syntax. No intermediate files are generated. GCC 3.x named
operands are supported.
@item @code{__builtin_types_compatible_p()} and @code{__builtin_constant_p()}
are supported.
@item @code{#pragma pack} is supported for win32 compatibility.
@end itemize
@section TinyCC extensions
( run in 0.557 second using v1.01-cache-2.11-cpan-e1769b4cff6 )