Hi,
On Fri, 11 Jan 2019, Petr Skočík wrote:
Having __STDC_VERSION__ reflect the -std= command option is great.
However, I think that disallowing _Generic and _Alignof at lower
versions is unnecessarily pedantic (as in a behavior more suitable for
compiler runs invoked with `-pedantic`). Unlike max_align_t, _Generic
and _Alignof are reserved identifiers in any C version. They shouldn't
ever need to be hidden. Hiding them can unnecessarily break some project
builds that use tcc with _Generic or _Alignof and without -std=c11.
Agreed. We should remember the name: _tiny_ cc. Pedantism stands against
that. If people want their code checked for conformance they should use a
different compiler. Already the changes between c11 and c99 seem too
pedantic for my taste, I'd have left in the max_align_t typedef even in
C99. If people complain that this isn't conforming, then so what? There
are so many other things not being conforming in tcc that this seems like
a useless corner case.
I certainly don't want to see TCCs sourcebase becoming sprinkled with a
myriad of 'if (stdc11 || stdc99)' conditionals.
Having said this, I don't object to the patches that now went in.
Ciao,
Michael.
Petr S.
On 1/10/19 11:47 PM, uso ewin wrote:
On Thu, Jan 10, 2019 at 2:47 PM Christian Jullien <[email protected]> wrote:
Matthias,
I'm happy you like my patch. I was waiting for comments before pushing this
patch.
As you said, no one protested (or care), so it is committed in mod.
It let you add the logic for the C11.
Christian
-----Original Message-----
From: Tinycc-devel [mailto:[email protected]]
On Behalf Of uso ewin
Sent: jeudi 10 janvier 2019 11:13
To: [email protected]
Subject: Re: [Tinycc-devel] Add max_align_t to stddef.h and C11
On Tue, Jan 8, 2019 at 6:02 PM Christian Jullien <[email protected]> wrote:
Maybe add a global variable
Not global but a new member of TCCState, for example cversion
If (s->cversion >= 201112) {
/* Hello C11 */
}
Diff becomes:
jullien@sims3:~/new-tcc $ git diff
diff --git a/libtcc.c b/libtcc.c
index df7adab..7883734 100644
--- a/libtcc.c
+++ b/libtcc.c
@@ -1790,8 +1790,16 @@ 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");
+ s->cversion = 201112;
+ }
+ }
+ /* 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"
diff --git a/tcc.h b/tcc.h
index cc85291..8416cc5 100644
--- a/tcc.h
+++ b/tcc.h
@@ -651,6 +651,7 @@ struct TCCState {
int rdynamic; /* if true, all symbols are exported */
int symbolic; /* if true, resolve symbols in the current module first
*/
int filetype; /* file type for compilation (NONE,C,ASM) */
+ int cversion; /* supported C ISO version, either 0 (199901), 201112,
... */
char *tcc_lib_path; /* CONFIG_TCCDIR or -B option */
char *soname; /* as specified on the command line (-soname) */
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
I like the version with cversion in tcc state.
As no one protest, I guess you can push.
Do you want to patch existing C11 code too ?
if not I can do it, but I need this patch to be merge.
Matthias,
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
Hi,
I've push the patch to allow _Alignof and _Generic only when -std=c11 is use.
Matthias,
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel
_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel