OSX GCC, 'dispatch_block_t' has not been declared, invalid typedef
In OSX 10.10 Yosemite the
/usr/include/dispatch/object.h
header file contains code that can be processed by clang but not GCC. The specific error that GCC 4.9 (via homebrew) produces is:
/usr/include/dispatch/object.h:143:15: error: expected unqualified-id before '^' token
typedef void (^dispatch_block_t)(void);
^
/usr/include/dispatch/object.h:143:15: error: expected ')' before '^' token
/usr/include/dispatch/object.h:362:3: error: 'dispatch_block_t' has not been declared
dispatch_block_t notification_block);
^
The fix:
//Change
typedef void (^dispatch_block_t)(void);
//To
typedef void* dispatch_block_t;
Similarly if using Xcode, the file is located at:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/dispatch/object.h dispatch/object.h