XS::TCC and OSX

There is three issues around XS::TCC and OSX.

1. libtcc can't detect warnings and errors.

libtcc's error_func don't pass the information around warnings. It's ugly. libtcc gets the is_warning flag but don't pass it to the callback function.

Then, XS::TCC can't handle warnings as warnings.

2. OSX FAIL

And so, sys/cdefs.h uses #warning in the header file.

In file included from /Users/tokuhirom/dev/p5-XS-TCC/tcc.c:1:
In file included from /usr/include/sys/types.h:75:
/usr/include/sys/cdefs.h:81: warning: #warning "Unsupported compiler detected"

Oh... It's depended on gcc...!

/* This SDK is designed to work with clang and specific versions of
* gcc >= 4.0 with Apple's patch sets */
#if !defined(__GNUC__) || __GNUC__ < 4
#warning "Unsupported compiler detected"
#endif

3. OSX library don't support tcc.

With this code,

#include <sys/types.h>
int main() { }

tcc dies with following message.

/usr/lib/crt1.o:1: error: unrecognized file type
tcc: error: file 'crt1.o' not found
tcc: error: file 'crti.o' not found
In file included from /Users/tokuhirom/dev/p5-XS-TCC/tcc.c:1:
In file included from /usr/include/sys/types.h:75:
/usr/include/sys/cdefs.h:81: warning: #warning "Unsupported compiler detected"
In file included from /Users/tokuhirom/dev/p5-XS-TCC/tcc.c:1:
In file included from /usr/include/sys/types.h:81:
In file included from /usr/include/machine/endian.h:35:
In file included from /usr/include/i386/endian.h:99:
In file included from /usr/include/sys/_endian.h:124:
/usr/include/libkern/_OSByteOrder.h:99: error: ';' expected (got "_OSSwapInt16")

This issue was noted on tcc-ml, see http://comments.gmane.org/gmane.comp.compilers.tinycc.devel/325.

Here is workaround, you can put following lines in your code:

typedef unsigned short __uint16_t, uint16_t;
typedef unsigned int __uint32_t, uint32_t;
typedef unsigned long __uint64_t, uint64_t;

Published: 2013-08-27(Tue) 19:47