Skip to content

Commit b29690e

Browse files
committed
work
1 parent 2afc426 commit b29690e

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

‎tests/unit/macros.cpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#include <stdio.h>
2+
#include <string.h>
3+
4+
const char *base_name(const char *path) {
5+
const char *slash = strrchr(path, '/');
6+
return slash ? slash + 1 : path;
7+
}
28

39
void log(const char *file, int line, const char *func) {
410
printf("%s %d %s\n", file, line, func);
@@ -11,7 +17,7 @@ const char *function() { return __builtin_FUNCTION(); }
1117
int main() {
1218
printf("%s %d %s\n", __FILE__, __LINE__, __FUNCTION__);
1319
log(__FILE__, __LINE__, __FUNCTION__);
14-
log(__FILE__, __builtin_LINE(), __builtin_FUNCTION());
20+
log(base_name(__builtin_FILE()), __builtin_LINE(), __builtin_FUNCTION());
1521
printf("%d %s\n", line(), function());
1622
return 0;
1723
}

0 commit comments

Comments
 (0)