# HG changeset patch # User Sebastien Jodogne # Date 1780501829 -7200 # Node ID 2349088c03b4be69e81d122e87c50599943ee057 # Parent 7a09008728f55f4aa26c03dce23652b0df19f409 fix THROW_WITH_FILE_AND_LINE_INFO macro diff -r 7a09008728f5 -r 2349088c03b4 OrthancFramework/Sources/OrthancException.h --- a/OrthancFramework/Sources/OrthancException.h Wed Jun 03 16:43:52 2026 +0200 +++ b/OrthancFramework/Sources/OrthancException.h Wed Jun 03 17:50:29 2026 +0200 @@ -31,12 +31,19 @@ #include #include // For uint16_t +#define THROW_WITH_FILE_AND_LINE_INFO(errorCode) throw OrthancException(errorCode) + #if ORTHANC_ENABLE_LOGGING == 1 - #define STRINGIFY_LINE_HELPER(line) #line - #define STRINGIFY_LINE(line) STRINGIFY_LINE_HELPER(line) - #define THROW_WITH_FILE_AND_LINE_INFO(errorCode) throw OrthancException(errorCode, #errorCode " triggered from " __ORTHANC_FILE__ ":" STRINGIFY_LINE(__LINE__)) -#else - #define THROW_WITH_FILE_AND_LINE_INFO() throw OrthancException(errorCode) +// The macro __ORTHANC_FILE__ is only defined for gcc and clang, and if DefineSourceBasenameForTarget is called in CMake +# if defined(__ORTHANC_FILE__) +# undef THROW_WITH_FILE_AND_LINE_INFO +# define ORTHANC_EXCEPTION_STRINGIFY_LINE_HELPER(line) #line +# define ORTHANC_EXCEPTION_STRINGIFY_LINE(line) ORTHANC_EXCEPTION_STRINGIFY_LINE_HELPER(line) +# define THROW_WITH_FILE_AND_LINE_INFO(errorCode) \ + throw OrthancException( \ + errorCode, #errorCode " triggered from " __ORTHANC_FILE__ ":" \ + ORTHANC_EXCEPTION_STRINGIFY_LINE(__LINE__)) +# endif #endif namespace Orthanc