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: Elijah Stone
Subject: Re: [Tinycc-devel] Identifying mob build via preprocessor
Date: Mon, 9 Aug 2021 18:33:24 -0700 (PDT)

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.

 -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]