I would like to know whether coloring the output of a program is a good practice and if it reduces portability. For example, printing an error message in red:
When I compile and run the program it shows color both in the terminal emulator and the virtual terminal (switching by pressing Ctrl + Alt + F1) in my GNU/Linux system. Some GNU utilities also have an optional --color flag to enable color, but I wonder if this can reduce portability in other cases like executing it in Windows.Code:#include <stdio.h> #include <stdlib.h> #define RED "\x1b[1;31m" #define NO_COLOR "\x1b[0m" ... printf("%sAn error ocurred.%s\n", RED, NO_COLOR); exit(1); ...
Should colors be used?
Thanks in advance.