Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for TCC #138

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

sleeptightAnsiC
Copy link

Hi,

I've tested boost.predef against TCC and it works just fine besides detecting the compiler itself.
This PR adds support for it by checking __TINYC__ macro and setting the corresponding version.
TCC is not a C++ compiler, but since boost.predef supports C, I thought it would be nice to add.

Tiny C Compiler (or TinyCC or TCC for short) is a minimal implementation of GCC-like compiler, aiming for fast compile times. It supports AnsiC, C99 and partially C11 with some GNUC extensions. Development is a bit staled (with latest release being in 2017) but it is still alive and some FOSS projects support it.

References:
https://repo.or.cz/w/tinycc.git
https://en.wikipedia.org/wiki/Tiny_C_Compiler

Adds support for detecting TCC by checking for __TINYC__ macro.
TCC pre-defines environment-specific macros similar to the ones
used by GCC and Clang so the rest of library works out of the box.
@grafikrobot
Copy link
Member

Thank you for the contribution. I'm looking into adding TCC testing to verify works as expected.

@sleeptightAnsiC
Copy link
Author

Thanks for taking a look at this @grafikrobot ,

If you're are looking for some more info, references and rationale for this change, here you go:
(I probably should mention these in my first message)

I hope this will help you.
I really want this compiler to get a better recognition and support.
I's super super usefult for C projects

$ uname -a ; tcc --version ; echo | tcc -dM -E -
Linux MAL200424 6.12.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Thu, 02 Jan 2025 22:52:26 +0000 x86_64 GNU/Linux
tcc version 0.9.28rc 2024-10-27 mob@a21b5f1f (x86_64 Linux)
#define __TINYC__ 928
#define __x86_64__ 1
#define __amd64__ 1
#define __linux__ 1
#define __linux 1
#define __unix__ 1
#define __unix 1
#define __TCC_PP__ 1
#define __SIZEOF_POINTER__ 8
#define __SIZEOF_LONG__ 8
#define __STDC__ 1
#define __STDC_VERSION__ 199901L
#define __SIZE_TYPE__ unsigned long
#define __PTRDIFF_TYPE__ long
#define __LP64__ 1
#define __INT64_TYPE__ long
#define __SIZEOF_INT__ 4
#define __INT_MAX__ 0x7fffffff
#define __LONG_MAX__ 0x7fffffffffffffffL
#define __SIZEOF_LONG_LONG__ 8
#define __LONG_LONG_MAX__ 0x7fffffffffffffffLL
#define __CHAR_BIT__ 8
#define __ORDER_LITTLE_ENDIAN__ 1234
#define __ORDER_BIG_ENDIAN__ 4321
#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
#define __WCHAR_TYPE__ int
#define __WINT_TYPE__ unsigned int
#define __UINTPTR_TYPE__ unsigned __PTRDIFF_TYPE__
#define __INTPTR_TYPE__ __PTRDIFF_TYPE__
#define __INT32_TYPE__ int
#define __REDIRECT(name,proto,alias) name proto __asm__(#alias)
#define __REDIRECT_NTH(name,proto,alias) name proto __asm__(#alias)__THROW
#define __REDIRECT_NTHNL(name,proto,alias) name proto __asm__(#alias)__THROWNL
#define __PRETTY_FUNCTION__ __FUNCTION__
#define __has_builtin(x) 0
#define __has_feature(x) 0
#define __has_attribute(x) 0
#define _Nonnull
#define _Nullable
#define _Nullable_result
#define _Null_unspecified
#define __BASE_FILE__ "-"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants