Use [[noreturn]] instead of declspec(noreturn)
MODIFY
include/vcpkg_Checks.h
include/vcpkg_Checks.h
namespace vcpkg::Checks
{
- __declspec(noreturn) void unreachable(const LineInfo& line_info);
+ [[noreturn]]
+ void unreachable(const LineInfo& line_info);
- _declspec(noreturn) void exit_with_code(const LineInfo& line_info, const int exit_code);
+ [[noreturn]]
+ void exit_with_code(const LineInfo& line_info, const int exit_code);
- _declspec(noreturn) inline void exit_fail(const LineInfo& line_info)
+ [[noreturn]]
+ inline void exit_fail(const LineInfo& line_info)
{
exit_with_code(line_info, EXIT_FAILURE);
}
- _declspec(noreturn) inline void exit_success(const LineInfo& line_info)
+ [[noreturn]]
+ inline void exit_success(const LineInfo& line_info)
{
exit_with_code(line_info, EXIT_SUCCESS);
}
// Part of the reason these exist is to not include extra headers in this one to avoid circular #includes.
- _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage);
+ [[noreturn]]
+ void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage);
template <class Arg1, class...Args>
- _declspec(noreturn) void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
+ [[noreturn]]
+ void exit_with_message(const LineInfo& line_info, const char* errorMessageTemplate, const Arg1 errorMessageArg1, const Args&... errorMessageArgs)
{
exit_with_message(line_info, Strings::format(errorMessageTemplate, errorMessageArg1, errorMessageArgs...));
}

MODIFY
include/vcpkg_Enums.h
include/vcpkg_Enums.h
@@ -6,5 +6,6 @@ namespace vcpkg::Enums
{
std::string nullvalue_toString(const std::string& enum_name);
- __declspec(noreturn) void nullvalue_used(const LineInfo& line_info, const std::string& enum_name);
+ [[noreturn]]
+ void nullvalue_used(const LineInfo& line_info, const std::string& enum_name);
}

MODIFY
src/vcpkg_Checks.cpp
src/vcpkg_Checks.cpp
namespace vcpkg::Checks
{
- __declspec(noreturn) void unreachable(const LineInfo& line_info)
+ [[noreturn]]
+ void unreachable(const LineInfo& line_info)
{
System::println(System::color::error, "Error: Unreachable code was reached");
System::println(System::color::error, line_info.toString()); // Always print line_info here
@@ -16,6 +17,7 @@ namespace vcpkg::Checks
#endif
}
+ [[noreturn]]
void exit_with_code(const LineInfo& line_info, const int exit_code)
{
if (g_debugging)
@@ -26,7 +28,8 @@ namespace vcpkg::Checks
::exit(exit_code);
}
- __declspec(noreturn) void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage)
+ [[noreturn]]
+ void exit_with_message(const LineInfo& line_info, const cstring_view errorMessage)
{
System::println(System::color::error, errorMessage);
exit_fail(line_info);

MODIFY
src/vcpkg_Enums.cpp
src/vcpkg_Enums.cpp
@@ -9,7 +9,8 @@ namespace vcpkg::Enums
return Strings::format("%s_NULLVALUE", enum_name);
}
- __declspec(noreturn) void nullvalue_used(const LineInfo& line_info, const std::string& enum_name)
+ [[noreturn]]
+ void nullvalue_used(const LineInfo& line_info, const std::string& enum_name)
{
Checks::exit_with_message(line_info, "NULLVALUE of enum %s was used", enum_name);
}

Use [[noreturn]] instead of declspec(noreturn)