2016-04-04 20:30:26 +08:00
|
|
|
typedef unsigned short uint16_t;
|
|
|
|
typedef unsigned char uint8_t;
|
|
|
|
|
|
|
|
typedef union Unaligned16a {
|
|
|
|
uint16_t u;
|
|
|
|
uint8_t b[2];
|
|
|
|
} __attribute__((packed)) Unaligned16a;
|
|
|
|
|
|
|
|
typedef union __attribute__((packed)) Unaligned16b {
|
|
|
|
uint16_t u;
|
|
|
|
uint8_t b[2];
|
|
|
|
} Unaligned16b;
|
|
|
|
|
2017-07-14 23:42:48 +08:00
|
|
|
extern void foo (void) __attribute__((stdcall));
|
|
|
|
void __attribute__((stdcall)) foo (void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2018-07-29 00:55:54 +08:00
|
|
|
/* The actual attribute isn't important, must just be
|
|
|
|
parsable. */
|
|
|
|
#define ATTR __attribute__((__noinline__))
|
|
|
|
int ATTR actual_function() {
|
|
|
|
return 42;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern int printf (const char *, ...);
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
void *function_pointer = &actual_function;
|
|
|
|
|
|
|
|
int a = ((ATTR int(*) (void)) function_pointer)();
|
|
|
|
printf("%i\n", a);
|
|
|
|
|
|
|
|
/* In the following we once misparsed 'ATTR *' is a btype
|
|
|
|
and hence the whole type was garbled. */
|
|
|
|
int b = ( (int(ATTR *)(void)) function_pointer)();
|
|
|
|
printf("%i\n", b);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|