tinycc-devel
[Top][All Lists]
Advanced

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

Re: [Tinycc-devel] RFC: Colored warnings/errors ?


From: avih
Subject: Re: [Tinycc-devel] RFC: Colored warnings/errors ?
Date: Sun, 12 May 2024 07:20:13 +0000 (UTC)

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.sauzede@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

reply via email to

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