Can't compile a C program on a Mac after upgrading to Catalina 10.15
For me adding the following path to CPATH
solved the issue:
export CPATH=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include
Error installing/bundling gem unf_ext -v '0.0.6'
It's a bug in the new xcode tools. It broke eventmachine in my case. See Missing C++ header <__debug> after updating OSX Command Line Tools 6.3 for answers with dummy files and reinstallation links. I downgraded to 6.2 and the problem went away.
Unable to install therubyracer on clean install of Yosemite and clean version of ruby
I was able to solve this by re-installing Command Line Tools for XCode 6.2 (instead of those for XCode 6.3).
There's more discussion in Stack Overflow 29529455.
enum to string in modern C++11 / C++14 / C++17 and future C++20
Magic Enum header-only library provides static reflection for enums (to string, from string, iteration) for C++17.
#include <magic_enum.hpp>
enum Color { RED = 2, BLUE = 4, GREEN = 8 };
Color color = Color::RED;
auto color_name = magic_enum::enum_name(color);
// color_name -> "RED"
std::string color_name{"GREEN"};
auto color = magic_enum::enum_cast<Color>(color_name)
if (color.has_value()) {
// color.value() -> Color::GREEN
};
For more examples check home repository https://github.com/Neargye/magic_enum.
Where is the drawback?
This library uses a compiler-specific hack (based on __PRETTY_FUNCTION__
/ __FUNCSIG__
), which works on Clang >= 5, MSVC >= 15.3 and GCC >= 9.
Enum value must be in range [MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]
.
By default
MAGIC_ENUM_RANGE_MIN = -128
,MAGIC_ENUM_RANGE_MAX = 128
.If need another range for all enum types by default, redefine the macro
MAGIC_ENUM_RANGE_MIN
andMAGIC_ENUM_RANGE_MAX
.MAGIC_ENUM_RANGE_MIN
must be less or equals than0
and must be greater thanINT16_MIN
.MAGIC_ENUM_RANGE_MAX
must be greater than0
and must be less thanINT16_MAX
.If need another range for specific enum type, add specialization enum_range for necessary enum type.
#include <magic_enum.hpp>
enum number { one = 100, two = 200, three = 300 };
namespace magic_enum {
template <>
struct enum_range<number> {
static constexpr int min = 100;
static constexpr int max = 300;
};
}
Related Topics
Delete All Items from a C++ Std::Vector
How to Use the _Attribute_((Visibility("Default")))
Exclude Source File in Compilation Using Makefile
How to Use C++ Std::Ostream with Printf-Like Formatting
Manual for Cross-Compiling a C++ Application from Linux to Windows
Default Move Constructor/Assignment and Deleted Copy Constructor/Assignment
Forward Declaration VS Include
How to Do a #Define Inside of Another #Define
Virtual Dispatch Implementation Details
How to Compile Openssl for X64
Qt: How to Handle the Event of the User Pressing the 'X' (Close) Button
How to Assign Multiple Values into a Struct at Once
Pointing to a Function That Is a Class Member - Glfw Setkeycallback
What's the Best Way to Check If a File Exists in C++? (Cross Platform)
C++: Wrapping Vector<Char> with Istream
Windows & C++: Extern & _Declspec(Dllimport)
Is Is a Good Practice to Put the Definition of C++ Classes into the Header File