tinycc-devel
[Top][All Lists]
Advanced

[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: Sun, 13 Jan 2019 07:30:28 +0100

Thank you Michael for your feedback.
I don't agree with you for c11 flag.
I participate to C++ standardization committee (which includes links to C).
We really take care of visible names and available features. That's why C
now includes more and more __STDC_xxx to detect what features are present or
not.
It greatly helps to write portable code.

For instance, my OpenLisp ISLISP compiler has been compiled on over 150
autoconf triplets (that's big).

Suppose I want to use VLA in a portable way. I'll probably write code like:

#if defined(__STDC__) && (__STDC_VERSION__ >= 201112L) &&
!defined(__STDC_NO_VLA__)
..
#else
#endif

In order to work, I'll pass all the relevant flags to any C compiler to ask
for C11 support. Otherwise, I'll have to pay attention to specific compiler
name and version which is pain to maintain.

Another option is to pretend that tcc is already C11 (and with all mandatory
__STDC_xxx feature tests) which is not true atm (I'm trying to add them when
C11 flag is set).

Sometimes, my code is as ugly as:

#if (defined(_WINDOWS_SOURCE) \
     && ((defined(_MSC_VER)&& (_MSC_VER >= 1100))     \
         || (defined(__DMC__))                        \
         || (defined(__GNUC__))                       \
         || (defined(__LCC__))                        \
         || (defined(__TINYC__))                      \
         || (defined(__POCC__))                       \
         || (defined(_WIN32_WCE))))
#define HAVE_PERFORMANCE_COUNTERS

Anyway, I thank you to accept patch already done.

C.

-----Original Message-----
From: Tinycc-devel [mailto:address@hidden
On Behalf Of Michael Matz
Sent: dimanche 13 janvier 2019 01:58
To: address@hidden
Subject: Re: [Tinycc-devel] Add max_align_t to stddef.h and C11

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 <address@hidden>
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:address@hidden
>>> On Behalf Of uso ewin
>>> Sent: jeudi 10 janvier 2019 11:13
>>> To: address@hidden
>>> Subject: Re: [Tinycc-devel] Add max_align_t to stddef.h and C11
>>>
>>> On Tue, Jan 8, 2019 at 6:02 PM Christian Jullien <address@hidden>
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:
>>>>
>>>> address@hidden:~/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
>>>> address@hidden
>>>> 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
>>> address@hidden
>>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>>
>>>
>>> _______________________________________________
>>> Tinycc-devel mailing list
>>> address@hidden
>>> 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
>> address@hidden
>> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>>
>
>
> _______________________________________________
> Tinycc-devel mailing list
> address@hidden
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>




reply via email to

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