Open twestenkarl opened 1 year ago
Notes:
I noticed a few places where it still contains throw, which caused build errors for me. Including but not limited to:
I removed the remaining throws and built it successfully without exceptions.
https://github.com/t123yh/yaml-cpp/commit/12520bd8817077b1b025d810aa135045c73f4893
There are currently three issues for supporting compilation without exceptions resolves #196 (closed with no changes) resolves #799 (open, no interaction) resolves #930 (open, no interaction)
these issue mention the following use case: using the library for a project where external constraints force it to build without exceptions (e.g. game development, embedded)
My use case is a C++ application that I compile with exceptions enabled for Linux/Windows but also with emscripten for WebAssembly where I disable exceptions.
1) A new macro
YAML_CPP_NORETURN
to annotate functions as not returning indll.h
2) A new functionYAML_throw<ExceptionType>(args...)
inexception.h
this function will throw an exception unless exceptions are disabled in the compiler, detected by checking the pre-defined macro__cpp_exceptions
In this case the exception class will be instantiated, and the user-provided functionYAML::handle_exception(const char*)
will be called on the exception'swhat()
method 3) if exceptions are disabled,and the library's user does not provideYAML::handle_exception
, there will be a linker error 4) all other files have been changed automatedly by running the following sed commandssed -i "s/throw \([A-Za-z]*\)(\(.*\))/YAML_throw<\1>(\2)/g"
throw statements for non-templated exceptionssed -i "s/throw \(.*\)<\(.*\)>(/YAML_throw<\1<\2> >(/g"
throw statements for templated exceptions