diff options
| author | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-13 16:04:29 -0700 |
|---|---|---|
| committer | Alexander Karatarakis <alkarata@microsoft.com> | 2017-03-13 16:04:29 -0700 |
| commit | e3bba294b4b08887851382573a7f2c73545e85fb (patch) | |
| tree | c71f8ddae944a5c5b43eca18fedc5919122d2e84 | |
| parent | a1d38868ab2998f07cc0f44fa1f747fe0cb7d5bb (diff) | |
| download | vcpkg-e3bba294b4b08887851382573a7f2c73545e85fb.tar.gz vcpkg-e3bba294b4b08887851382573a7f2c73545e85fb.zip | |
Introduce LINE_INFO macro + struct
| -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() |
