Thanks all for the useful feedback.
Indeed, colored output are not absolutely required for a compiler.
And one of Tinycc values is its small size & complexity.

For my use-case though, ie: fast interactive TDD loop, I need such visual
cues.

But I didn't think that a simple post-process filter would be efficient..

So I ended up just using this filter:
```
bred="\x1b[1;31m"
bwhite="\x1b[1;37m"
nrm="\x1b[0m"
sed -e "s/\(error:\)/$bred\1$nrm/g" -e "s/\(^.*:.*:\)/$bwhite\1$nrm/g" -e
"s/'\(.*\)'/'$bwhite\1$nrm'/g"
```
And it works fine!
No need to touch/fork tcc code, indeed..

BR,
NS.

On Sun, May 12, 2024 at 9:21 AM avih via Tinycc-devel <
tinycc-devel@nongnu.org> wrote:

> Personally I don't think this is required, but I don't pretend to
> represent the tinycc maintainers' opinion. If it is added, however,
> then the following should probably be taken into account:
>
> - This mostly works, but it won't work on all terminals, for instance
> the original DEC VT100 has bold but doesn't have colors.
>
> - It's probably better to support disabling it by means other than
> piping stderr into "cat" (so that stdout is not a tty). I.e. using
> an option, probably with value always/never/auto. Preferably it
> should also respect NO_COLOR by default. see https://no-color.org/ .
>
> - This won't work on Windows before 10, e.g. Windows xp/7/8.
>
> - On Windows 10+ this only works if the console/termimal has VT
> enabled - which is disabled by default, or if it runs in
> a terminal which supports VT (like mintty in MSYS2 or cygwin).
> To test if VT is enabled (untested, off the top of my head):
> DWORD mode; int has_vt;
> has_vt = GetConsoleMode(GetStdHandle(STD_ERROR_HANDLE), &mode) &&
> (mode & ENABLE_VIRTUAL_TERMINAL_PROCESSING);
> Note that ENABLE_VIRTUAL_TERMINAL_PROCESSING is new-ish and not
> defined in the tcc windows headers, so the code above would fail if
> compiled in tcc. You can define it as 4 if it's not defined.
> If you go this path, it should be used when compiling on windows
> (not when the target is windows).
>
> - avih
>
> On Sunday, May 12, 2024 at 02:36:25 AM GMT+3, Nicolas Sauzede <
> nicolas.sauz...@gmail.com> wrote:
>
>
> Hi,
>
> I created a very simple mob branch to color warnings/errors output, just
> like GCC and Clang.
>
>     $ git fetch origin 
> refs/mob/mob_nsauzede/colored_warning_error:colored_warning_error    $ git 
> checkout colored_warning_error
>
>
> I tested it successfully on Linux (Arch) and Windows (MSYS2, 64 bits GCC
> bootstrap)
> It uses `isatty(2)` (unistd.h) to detect if the output should be colored
> (default) or not (eg: piped to a file) to behave like GCC and Clang.
>
> What do you think ?
>
> BR,
> NS.
> _______________________________________________
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
> _______________________________________________
> Tinycc-devel mailing list
> Tinycc-devel@nongnu.org
> https://lists.nongnu.org/mailman/listinfo/tinycc-devel
>
_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to