Monday, September 8, 2008

Fun With Digraphs

Christ, I can't believe this compiles-
%:include <stdio.h>
%:include <Cocoa/Cocoa.h>

int main()
NSString *message = @"Hello, world";

printf("%s\n", <:message UTF8String:>);

return 0;

It's section 6.4.6 in the C spec. Good stuff for playing jokes on coworkers, but please don't ship code like this.


Peter Hosey said...

You think digraphs are bad? You must not have seen trigraphs (§…

To wit…

Blake C. said...

Nice bug :)

I've seen trigraphs, but I don't think they're enabled by default. Digraphs appear to work with no extra flags.