tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] Identifying mob build via preprocessor


From: Michael Matz
Subject: Re: [Tinycc-devel] Identifying mob build via preprocessor
Date: Tue, 10 Aug 2021 15:03:27 +0200 (CEST)
User-agent: Alpine 2.21 (LSU 202 2017-01-01)

Hello,

On Mon, 9 Aug 2021, Elijah Stone wrote:

IMO a cleaner solution would be to support clang's __has_feature/__has_builtin/__has_extension. This:

- Is clearer: says exactly what you mean.

- Is less error-prone; if a feature goes away in a later version or in
  some configuration, or if you typo'd the version number in the first
  place, version checking will fail but feature checking won't.

- Doesn't disadvantage newer compilers, which might have implemented the
  extension you need but which your codebase didn't manually check for.
  (The way all compilers pretend to be __GNUC__ reminds me of the way all
  browsers pretend to be Mozilla.)

The disadvantage is that it's harder to implement.

And larger :) I think the patch as-is is a good one (though maybe count from initial commit, not from the 0.9.27 release?), even though that macro will be awkwardish to use (and with the disadvantages you named). I agree that the __has_*() predicates are better to use, but do note that it only fulfills the promised features if the names you put into the argument are agreed upon by compilers (or just taken from GCC or clang, as appropriate). I would not let that better feature hold up the inclusion of the __TINYC_MOB__ patch.


Ciao,
Michael.

-E

On Mon, 9 Aug 2021, Alvarito050506 wrote:

 Hello!

 I'm currently using TCC for testing and experimenting because it's
 blazing fast (amazing work, by the way), and some libraries depend on
 GNU C features which are actually implemented in the `mob` branch, but
 the libraries only check for GCC and Clang, so I would like to send a
 few patches that would make them check for TCC > 0.9.27 too.

 The problem is, as far as I know, there is currently no way to detect
 a build from the `mob` branch, and using `__TINYC__` wouldn't an
 option since it doesn't change anymore.

 I made a small patch that defines `__TINYC_MOB__` as the number of
 commits since 0.9.27, and could be used like the following:

 /* Detect support for the cleanup attribute */
 #if defined(__GNUC__) || defined(__clang__) ||
     defined(__TINYC_MOB__) && __TINYC_MOB__ >= 68
 /* ... */

 I wonder if there is a better way to do this, and if it would be OK to
 add something like this?

 Thanks,
 Álvaro.


reply via email to

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