[Top][All Lists]

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

Re: [Tinycc-devel] Add max_align_t to stddef.h and C11

From: Christian Jullien
Subject: Re: [Tinycc-devel] Add max_align_t to stddef.h and C11
Date: Tue, 8 Jan 2019 17:03:41 +0100

If no one protests, I can push this patch:
address@hidden:~/new-tcc $ git diff
diff --git a/libtcc.c b/libtcc.c
index df7adab..eb55d8a 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1790,8 +1790,15 @@ reparse:
             s->static_link = 1;
         case TCC_OPTION_std:
-           /* silently ignore, a current purpose:
-              allow to use a tcc as a reference compiler for "make test" */
+            if (*optarg == '=') {
+                ++optarg;
+                if (strcmp(optarg, "c11") == 0) {
+                   tcc_undefine_symbol(s, "__STDC_VERSION__");
+                   tcc_define_symbol(s, "__STDC_VERSION__", "201112L");
+                }
+            }
+             /* silently ignore other values, a current purpose:
+                allow to use a tcc as a reference compiler for "make test"
         case TCC_OPTION_shared:
             x = TCC_OUTPUT_DLL;
diff --git a/tcc.c b/tcc.c
index f780389..2d4e1ea 100644
--- a/tcc.c
+++ b/tcc.c
@@ -33,6 +33,8 @@ static const char help[] =
     "  -o outfile  set output filename\n"
     "  -run        run compiled source\n"
     "  -fflag      set or reset (with 'no-' prefix) 'flag' (see tcc -hh)\n"
+    "  -std=c99    Conform to the ISO 1999 C standard (default).\n"
+    "  -std=c11    Conform to the ISO 2011 C standard.\n"
     "  -Wwarning   set or reset (with 'no-' prefix) 'warning' (see tcc
     "  -w          disable all warnings\n"
     "  -v -vv      show version, show search paths or loaded files\n"

It allows to start to play with -std=c11 new option. It correctly handles
c11 and ignore all other values to be compatible with gcc.

address@hidden:~/new-tcc $ cat foo.c
#include <stdio.h>

main() {
        printf("__STDC_VERSION__ == %d\n", __STDC_VERSION__);
address@hidden:~/new-tcc $ ./tcc foo.c -o foo && ./foo
__STDC_VERSION__ == 199901
address@hidden:~/new-tcc $ ./tcc -std=c11 foo.c -o foo && ./foo
__STDC_VERSION__ == 201102
address@hidden:~/new-tcc $ ./tcc -std=c42 foo.c -o foo && ./foo
__STDC_VERSION__ == 199901

-----Original Message-----
From: Tinycc-devel [mailto:address@hidden
On Behalf Of uso ewin
Sent: mardi 8 janvier 2019 15:31
To: address@hidden
Subject: Re: [Tinycc-devel] Add max_align_t to stddef.h and C11

On Tue, Jan 8, 2019 at 2:35 PM Christian Jullien <address@hidden> wrote:
> The right solution is to start to implement C11 features and surround them
> with right #if _STDC_VERSION >= xxx.
> This is how gcc/Linux handle differences between C/C++/POSIX/...
> Even gcc is not totally fair when it claims it supports a given version.
> I spent several hours to figure out why my -std=c++11 regexp always
> false with gcc 4.8.2 until I discovered that <regexp> and all API was
> present ... BUT NOT IMPLEMENTED and all calls where returning error!!!
> I personally vote in favor of -std=c11 new option which supports ... only
> what is actually implemented (without complex for instance).
> What other maintainers think about by opinion?

I'm not a maintainer, but am totally in favor to add a support for -std=C11
and  maybe latter for -std=C99.

Tinycc-devel mailing list

reply via email to

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