I have a h file with this code:
#include <windows.h>
#include <iostream>
struct Color
{
int color;
Color(int color_): color(color_) {}
Color operator + (const Color & other) const { return Color(this->color | other.color); }
};
#define FORE_LIGHT(color) const Color cfl##color##_ = FOREGROUND_##color | FOREGROUND_INTENSITY;
#define BACK_LIGHT(color) const Color cbl##color##_ = BACKGROUND_##color | BACKGROUND_INTENSITY;
#define FORE_DARK(color) const Color cfd##color##_ = FOREGROUND_##color;
#define BACK_DARK(color) const Color cbd##color##_ = BACKGROUND_##color;
FORE_LIGHT(RED) FORE_LIGHT(GREEN) FORE_LIGHT(BLUE)
BACK_LIGHT(RED) BACK_LIGHT(GREEN) BACK_LIGHT(BLUE)
FORE_DARK (RED) FORE_DARK (GREEN) FORE_DARK (BLUE)
BACK_DARK (RED) BACK_DARK (GREEN) BACK_DARK (BLUE)
const Color cdefault_ = cfdRED_ + cfdGREEN_ + cfdBLUE_;
std::ostream & operator << (std::ostream & os, Color c)
{
return SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), c.color), os;
}
When I include this h file to another cpp file, no problem but if I include this to two files I have error multiply symbols found. Can somebody help me how to solve it?