Skip to content

Commit

Permalink
Add specific macros
Browse files Browse the repository at this point in the history
  • Loading branch information
gammasoft71 committed Oct 15, 2024
1 parent 67e93df commit 71a5e3d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/xtd.core/include/xtd/internal/__xtd_source_location.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@
#include <source_location>
using __xtd_source_location__ = std::source_location;
#else
#include <cstdint>

#define __XTD_FILE__ __builtin_FILE()
#define __XTD_LINE__ __builtin_LINE()
#define __XTD_FUNC__ __builtin_FUNCTION()
#define __XTD_COLUMN__ __builtin_COLUMN()

class __xtd_source_location__ {
public:
const char* file_name() const noexcept {return data_.file;}
uint32_t line() const noexcept {return data_.line;}
const char* function_name() const noexcept {return data_.func;}
uint32_t column() const noexcept {return data_.column;}

static __xtd_source_location__ current(const char* file = __builtin_FILE(), uint32_t line = __builtin_LINE(), const char* func = __builtin_FUNCTION(), uint32_t column = __builtin_COLUMN()) noexcept {
static __xtd_source_location__ current(const char* file = __XTD_FILE__, uint32_t line = __XTD_LINE__, const char* func = __XTD_FUNC__, uint32_t column = __XTD_COLUMN__) noexcept {
auto csl = __xtd_source_location__ {};
csl.data_ = {file, line, func, column};
return csl;
Expand All @@ -37,5 +44,10 @@ class __xtd_source_location__ {
uint32_t column;
} data_;
};

#undef __XTD_FILE__
#undef __XTD_LINE__
#undef __XTD_FUNC__
#undef __XTD_COLUMN__
#endif
/// @endcond

0 comments on commit 71a5e3d

Please sign in to comment.