gVirtualXRay
2.0.10
VirtualX-RayImagingLibraryonGPU
gvxr
include
gVirtualXRay
filesystem.h
Go to the documentation of this file.
1
// Even when enabling C++ 17 on OpenSUSE with g++ 7.5.0, filesystem is not available.
2
// It turned out that it's an experimental feature despite being part of the standard.
3
// This header takes care of including the right header and setting the right namespace.
4
// This way the code should be portable.
5
// See https://stackoverflow.com/questions/53365538/how-to-determine-whether-to-use-filesystem-or-experimental-filesystem
6
7
8
// We haven't checked which filesystem to include yet
9
#ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
10
11
// Check for feature test macro for <filesystem>
12
# if defined(__cpp_lib_filesystem)
13
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
14
15
// Check for feature test macro for <experimental/filesystem>
16
# elif defined(__cpp_lib_experimental_filesystem)
17
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
18
19
// We can't check if headers exist...
20
// Let's assume experimental to be safe
21
# elif !defined(__has_include)
22
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
23
24
// Check if the header "<filesystem>" exists
25
# elif __has_include(<filesystem>)
26
27
// If we're compiling on Visual Studio and are not compiling with C++17, we need to use experimental
28
# ifdef _MSC_VER
29
30
// Check and include header that defines "_HAS_CXX17"
31
# if __has_include(<yvals_core.h>)
32
# include <yvals_core.h>
33
34
// Check for enabled C++17 support
35
# if defined(_HAS_CXX17) && _HAS_CXX17
36
// We're using C++17, so let's use the normal version
37
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
38
# endif
39
# endif
40
41
// If the marco isn't defined yet, that means any of the other VS specific checks failed, so we need to use experimental
42
# ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
43
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
44
# endif
45
46
// Not on Visual Studio. Let's use the normal version
47
# else // #ifdef _MSC_VER
48
49
// First deal with an old version of CLang on MacOS
50
# if defined(__APPLE__) && __has_include(<experimental/filesystem>)
51
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
52
# else
53
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 0
54
# endif
55
# endif
56
57
// Check if the header "<filesystem>" exists
58
# elif __has_include(<experimental/filesystem>)
59
# define INCLUDE_STD_FILESYSTEM_EXPERIMENTAL 1
60
61
// Fail if neither header is available with a nice error message
62
# else
63
# error Could not find system header "<filesystem>" or "<experimental/filesystem>"
64
# endif
65
66
// We priously determined that we need the exprimental version
67
# if INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
68
69
// Include it
70
# include <experimental/filesystem>
71
72
// We need the alias from std::experimental::filesystem to std::filesystem
73
namespace
std
{
74
namespace
filesystem = experimental::filesystem;
75
}
76
77
// We have a decent compiler and can use the normal version
78
# else
79
// Include it
80
# include <filesystem>
81
# endif
82
83
#endif // #ifndef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
std
STL namespace.
Generated on Thu Jul 17 2025 11:16:56 for gVirtualXRay by
1.8.14