tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Tinycc-devel] What C version tcc is supposed to implement?


From: Christian Jullien
Subject: [Tinycc-devel] What C version tcc is supposed to implement?
Date: Sat, 16 Feb 2013 12:04:42 +0100

    tcc_define_symbol(s, "__STDC_VERSION__", "199901L");

This define pretends it is ISO/IEC 9899:1999 (E)

Because __STDC_VERSION__ is set to 199901L
This code should be legal:

#include <stdio.h>
#include <wchar.h>

int main()
{
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L)
        wchar_t* s = L"ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        char* p = (char*)s;
        printf("%x %x %x %x\n", p[0],p[1],p[2],p[3]);
        printf("%x %x %x %x\n", p[4],p[5],p[6],p[7]);
        wprintf(L"Hello World\n");
#else
        printf("Not an ISO C compiler\n");
#endif
}

It compiles with no error on RPi, treats wchar_t as an uint32_t (as on
Linux) yet does nothing with wprintf!
address@hidden ~ $ tcc foo.c -o foo && ./foo
41 0 0 0
42 0 0 0
address@hidden ~ $

If tcc is 199901L, as said in ISO/IEC 9899:1999 (E) it should also define:

_ _STDC_ _ The integer constant 1, intended to indicate a conforming
implementation.
_ _STDC_HOSTED_ _ The integer constant 1 if the implementation is a hosted
implementation or the integer constant 0 if it is not.
_ _STDC_VERSION_ _ The integer constant 199901L
_ _STDC_IEC_559_ _ The integer constant 1, intended to indicate conformance
to the
specifications in annex F (IEC 60559 floating-point arithmetic).
_ _STDC_IEC_559_COMPLEX_ _ The integer constant 1, intended to indicate
adherence to the specifications in informative annex G (IEC 60559
compatible complex arithmetic).
_ _STDC_ISO_10646_ _ An integer constant of the form yyyymmL (for example,
199712L), intended to indicate that values of type wchar_t are the
coded representations of the characters defined by ISO/IEC 10646, along
with all amendments and technical corrigenda as of the specified year and
month.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]