Jump to content

Talk:Tiny C Compiler

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

TCC ISO compliance

[edit]

As far as I know, the homepage states that it is an ISO C99 compliant C compiler, so I'm wondering about the significance of the statement about falling far short of a C90 compliant implementation. Zuiram 03:08, 20 December 2006 (UTC)[reply]

  • It's a mile away from C90 compliance. I have some simple C90 tests in front of me which only test compile-time conformance and are far from exhaustive. It fails 175 of 926 tests with 4 segfaults, as a comparison GCC fails 7 with no segfaults. Just two examples of failures are the following, which the standard requires a diagnostic for:
    • int f (float z) { switch (z) { default: return 1; } }
    • char *p; void f (signed char *q) { p = &q[1]; }

error

[edit]

In the section Compiled program performance, in the paragraph on rough benchmarks, there is a missing period in the last number. I suspect it should be .93. Rebele | Talk The only way to win the game is to not play the game. 09:41, 30 May 2010 (UTC)[reply]

Shebang

[edit]

@Vincent Lefèvre, I am addressing you here to avoid edit warring: my edits are cited and directly cite the official documentation of TCC. Just because This does not work: "bad interpreter: /usr/local/bin/tcc: no such file or directory"., in other words your own system is not configured to run it, has nothing to do with any of this. 24.50.56.74 (talk) 19:27, 10 September 2025 (UTC)[reply]

AFAIK, a typical Linux machine will try to execute /usr/local/bin/tcc directly without doing a path search. The issue of the official documentation has been mentioned several times in the Tinycc-devel mailing-list. This post suggests
#!/usr/bin/env -S tcc -run
instead, but I don't know how portable it is (POSIX Issue 8 (2024) does not specify the -S option). — Vincent Lefèvre (talk) 01:24, 11 September 2025 (UTC)[reply]
According to the Gentoo Wiki, the following notes are presented:
The Tiny C compiler can be run with a script if the proper shebang (#!) is set at the first line of the file. The official upstream documentation provides the shebang as:
#!/usr/local/bin/tcc -run
However, this is inaccurate on a Gentoo system. Presently, the dev-lang/tcc ebuild installs tcc to /usr/bin, thus the shebang should be:
#!/usr/bin/tcc -run
If the script is going to be run on multiple systems where the path to tcc might change, the following shebang is also technically possible:
#!/usr/bin/env -S tcc -run
Note that the -S option is widely available on Linux but it may or may not be present on other operating systems such as macOS or any of the BSD's. Thus, while it is technically valid it should be used with caution in highly homogeneous environments.
In addition, it's also possible to make a file that is also a valid C source file with:
//usr/bin/env tcc -run "$0" "$@" ; exit $?
Either way, whatever the "correct" way is, we should at least provide the fact that the official shebang given on the TCC website is #!/usr/local/bin/tcc -run. (I'm not sure what system you are running on, or what actually happens on different systems, but we could leave a note mentioning that such shebang may not necessarily be correct on other systems.)
24.50.56.74 (talk) 15:18, 11 September 2025 (UTC)[reply]
If you have nothing else to say I'm going to restore it with the note that the shebang may not work on some systems. 24.50.56.74 (talk) 14:47, 12 September 2025 (UTC)[reply]
Or say that #!/usr/local/bin/tcc -run assumes that tcc is installed as /usr/local/bin/tcc. But, IMHO, the official documentation should be fixed. I would rather see
// 2> /dev/null ; exec tcc -run "$0" "$@"
to avoid an intermediate shell waiting for the running program to terminate. — Vincent Lefèvre (talk) 20:50, 12 September 2025 (UTC)[reply]