aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/um/service
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--um/service/include/libservice/windows_error.hpp23
-rw-r--r--um/service/test/CMakeLists.txt5
-rw-r--r--um/service/utils/CMakeLists.txt8
3 files changed, 29 insertions, 7 deletions
diff --git a/um/service/include/libservice/windows_error.hpp b/um/service/include/libservice/windows_error.hpp
index f7ac90e..13d7f47 100644
--- a/um/service/include/libservice/windows_error.hpp
+++ b/um/service/include/libservice/windows_error.hpp
@@ -8,6 +8,7 @@
#include "common.hpp"
#include "singleton.hpp"
+#include <sstream>
#include <string>
#include <system_error>
@@ -25,7 +26,29 @@ namespace libservice
private:
friend class Singleton<WindowsErrorCategory>;
};
+
+ namespace error
+ {
+ inline std::string build_what(
+ const char* function,
+ const char* file,
+ int line)
+ {
+ std::ostringstream oss;
+ oss << "Error in function '" << function
+ << "' at file '" << file
+ << "', line " << line;
+ return oss.str();
+ }
+ }
}
+#if defined(_MSC_VER)
#define LIBSERVICE_ERROR_PREFIX \
"Error in function '" LIBSERVICE_FUNCTION_NAME "' at file '" LIBSERVICE_FILE_PATH "', line " LIBSERVICE_LINE_NUMBER_STRING
+#elif defined(__GNUC__)
+#define LIBSERVICE_ERROR_PREFIX \
+ libservice::error::build_what(LIBSERVICE_FUNCTION_NAME, LIBSERVICE_FILE_PATH, LIBSERVICE_LINE_NUMBER)
+#else
+#define LIBSERVICE_ERROR_PREFIX "Error"
+#endif
diff --git a/um/service/test/CMakeLists.txt b/um/service/test/CMakeLists.txt
index 4780deb..6825337 100644
--- a/um/service/test/CMakeLists.txt
+++ b/um/service/test/CMakeLists.txt
@@ -1,4 +1,3 @@
add_executable(libservice_test_windows_error windows_error.cpp)
-target_link_libraries(libservice_test_windows_error libservice)
-set_target_properties(libservice_test_windows_error PROPERTIES
- OUTPUT_NAME windows_error)
+target_link_libraries(libservice_test_windows_error PRIVATE libservice)
+set_target_properties(libservice_test_windows_error PROPERTIES OUTPUT_NAME windows_error)
diff --git a/um/service/utils/CMakeLists.txt b/um/service/utils/CMakeLists.txt
index 061ab25..fc5cc1b 100644
--- a/um/service/utils/CMakeLists.txt
+++ b/um/service/utils/CMakeLists.txt
@@ -1,11 +1,11 @@
add_executable(install_service install_service.cpp)
-target_link_libraries(install_service libservice)
+target_link_libraries(install_service PRIVATE libservice)
add_executable(start_service start_service.cpp)
-target_link_libraries(start_service libservice)
+target_link_libraries(start_service PRIVATE libservice)
add_executable(stop_service stop_service.cpp)
-target_link_libraries(stop_service libservice)
+target_link_libraries(stop_service PRIVATE libservice)
add_executable(uninstall_service uninstall_service.cpp)
-target_link_libraries(uninstall_service libservice)
+target_link_libraries(uninstall_service PRIVATE libservice)