If no one protests, I can push this patch: jullien@sims3:~/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; break; 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" */ break; 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 -hh)\n" " -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. jullien@sims3:~/new-tcc $ cat foo.c #include <stdio.h> int main() { printf("__STDC_VERSION__ == %d\n", __STDC_VERSION__); } jullien@sims3:~/new-tcc $ ./tcc foo.c -o foo && ./foo __STDC_VERSION__ == 199901 jullien@sims3:~/new-tcc $ ./tcc -std=c11 foo.c -o foo && ./foo __STDC_VERSION__ == 201102 jullien@sims3:~/new-tcc $ ./tcc -std=c42 foo.c -o foo && ./foo __STDC_VERSION__ == 199901 -----Original Message----- From: Tinycc-devel [mailto:tinycc-devel-bounces+eligis=orange...@nongnu.org] On Behalf Of uso ewin Sent: mardi 8 janvier 2019 15:31 To: tinycc-devel@nongnu.org Subject: Re: [Tinycc-devel] Add max_align_t to stddef.h and C11 On Tue, Jan 8, 2019 at 2:35 PM Christian Jullien <eli...@orange.fr> wrote: > > IMHO, > > 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 returned > 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 Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel _______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel