Baselib_SourceLocation.h 777 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #ifndef BASELIB_ENABLE_SOURCELOCATION
  3. #ifdef NDEBUG
  4. #define BASELIB_ENABLE_SOURCELOCATION 0
  5. #else
  6. #define BASELIB_ENABLE_SOURCELOCATION 1
  7. #endif
  8. #endif
  9. #ifdef __cplusplus
  10. BASELIB_C_INTERFACE
  11. {
  12. #endif
  13. // Human readable about the original location of a piece of source code.
  14. typedef struct Baselib_SourceLocation
  15. {
  16. const char* file;
  17. const char* function;
  18. uint32_t lineNumber;
  19. } Baselib_SourceLocation;
  20. // Macro to create source location in-place for the current line of code.
  21. #if BASELIB_ENABLE_SOURCELOCATION
  22. #define BASELIB_SOURCELOCATION Baselib_SourceLocation { __FILE__, __func__, __LINE__ }
  23. #else
  24. #define BASELIB_SOURCELOCATION Baselib_SourceLocation { NULL, NULL, 0 }
  25. #endif
  26. #ifdef __cplusplus
  27. }
  28. #endif