diff options
| -rw-r--r-- | toolsrc/include/vcpkg_Checks.h | 16 | ||||
| -rw-r--r-- | toolsrc/src/vcpkg_Checks.cpp | 8 |
2 files changed, 24 insertions, 0 deletions
diff --git a/toolsrc/include/vcpkg_Checks.h b/toolsrc/include/vcpkg_Checks.h index 23869f35f..c9293b0bb 100644 --- a/toolsrc/include/vcpkg_Checks.h +++ b/toolsrc/include/vcpkg_Checks.h @@ -2,6 +2,22 @@ #include "vcpkg_Strings.h" +namespace vcpkg +{ + struct LineInfo + { + int line_number; + const char* file_name; + + constexpr LineInfo() : line_number(0), file_name(nullptr) {} + constexpr LineInfo(const int line_number, const char* file_name) : line_number(line_number), file_name(file_name) {} + + std::string toString() const; + }; +} + +#define LINE_INFO vcpkg::LineInfo(__LINE__, __FILE__) + namespace vcpkg::Checks { __declspec(noreturn) void unreachable(); diff --git a/toolsrc/src/vcpkg_Checks.cpp b/toolsrc/src/vcpkg_Checks.cpp index 02d3480a2..caffb1a8f 100644 --- a/toolsrc/src/vcpkg_Checks.cpp +++ b/toolsrc/src/vcpkg_Checks.cpp @@ -2,6 +2,14 @@ #include "vcpkg_Checks.h" #include "vcpkg_System.h" +namespace vcpkg +{ + std::string LineInfo::toString() const + { + return Strings::format("%s(%d)", this->file_name, this->line_number); + } +} + namespace vcpkg::Checks { __declspec(noreturn) void unreachable() |
