C Defines for Printing Colors

June 14, 2021 - Reading time: ~1 minute

A header file to define colors to use when printing to the console in C.

#ifndef __COLORS_H_
#define __COLORS_H_
#define _COLOR_CYAN            "\x1b[36m"
#define _COLOR_VIOLET          "\x1b[35m"
#define _COLOR_GREEN           "\x1b[32m"
#define _COLOR_BLUE            "\x1b[34m"
#define _COLOR_YELLOW          "\x1b[33m"
#define _COLOR_RED             "\x1b[31m"
#define _COLOR_LRED            "\x1b[1;31m"
#define _COLOR_YELLOWONRED     "\x1b[1;33;41m"
#define _COLOR_UYELLOWONRED    "\x1b[1;4;5;33;41m"
#define _COLOR_RESET           "\x1b[0m"
#define _COLOR_OUTPUT          _COLOR_CYAN
#define _COLOR_DEBUG           _COLOR_VIOLET
#define _COLOR_INFO            _COLOR_GREEN
#define _COLOR_NOTICE          _COLOR_BLUE
#define _COLOR_WARNING         _COLOR_YELLOW
#define _COLOR_ERROR           _COLOR_RED
#define _COLOR_CRITICAL        _COLOR_LRED
#define _COLOR_ALERT           _COLOR_YELLOWONRED
#define _COLOR_EMERGENCY       _COLOR_UYELLOWONRED
#endif

Categories