I've been trying to find a "portable" way of stealing a semicolon from an include file. This works under Linux:
int main(int ac, char **av)
{
#define typedef
#define uint8_t a[printf("hello world\n")]
#include <stdint.h>
}
This causes the one typedef unsigned char uint8_t
to become my printf.
Another trick that worked was to #define
away every standard stdint type such that stdint.h
reduces to a bunch of semicolons.
Both of these fall flat on FreeBSD because it uses private intermediate types (like __uint8_t
) which means that removing typedef fails in the quoted example and prevents me from successfully removing all non-semicolons in the other case.
It seems like it should be possible to steal a semicolon cleanly from an include file. Can anyone improve on my attempt?