Skip to content

Commit 5202145

Browse files
committed
fallback source_location
1 parent c90bb21 commit 5202145

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/iso_fortran_binding/sampling.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
#include <algorithm>
1010
#include <vector>
1111
#include <string>
12+
13+
#if __has_include(<source_location>)
1214
#include <source_location>
15+
#endif
1316

1417
#include <ISO_Fortran_binding.h>
1518

@@ -54,8 +57,13 @@ std::string cfiGetErrorString(int stat) {
5457
void check_cfi(int s)
5558
{
5659
if (s != CFI_SUCCESS){
60+
#if defined(__cpp_lib_source_location)
5761
constexpr std::source_location loc = std::source_location::current();
58-
std::cerr << loc.file_name() << ":" << loc.line() << " CFI API failed with error: (" << s << ") " << cfiGetErrorString(s) << "\n";
62+
std::cerr << loc.file_name() << ":" << loc.line() <<
63+
#else
64+
std::cerr <<
65+
#endif
66+
" CFI API failed with error: (" << s << ") " << cfiGetErrorString(s) << "\n";
5967
}
6068
}
6169

0 commit comments

Comments
 (0)