From 74072cdc80bbcf108486403f4223c6a018f6daaf Mon Sep 17 00:00:00 2001 From: Melissa Jost Date: Thu, 13 Apr 2023 11:45:17 -0700 Subject: [PATCH] base: Update include This change addresses an error in the compiler tests: https://jenkins.gem5.org/job/compiler-checks/573/ For clang versions 6 through 10, as well as GCC 7, in order to use the "filesystem" module, you must include the experimental namespace. In all newer versions, you can use the "filesystem" module as is. Because of this, include guards to handle this. They include "" for the older clang versions and the "" for all other versions. As opposed to checking by version, we now check if the filesystem library has been defined before using it. Change-Id: I8fb8d4eaa33f3edc29b7626f44b82ee66ffe72be Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/69778 Maintainer: Bobby Bruce Tested-by: kokoro Reviewed-by: Bobby Bruce --- src/base/socket.cc | 13 ++++++++----- src/mem/shared_memory_server.cc | 14 +++++++++----- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/base/socket.cc b/src/base/socket.cc index 62f20717f4..06fc28631f 100644 --- a/src/base/socket.cc +++ b/src/base/socket.cc @@ -40,13 +40,16 @@ #include -#if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__) +// check if filesystem library is available +#if defined(__cpp_lib_filesystem) || __has_include() #include #else - // This is only reachable if we're using GCC 7 (note: gem5 does not support - // GCC versions older than GCC 7 as they do not support the C++17 - // standard). - // If we're using GCC 7, we need to use . + // This is only reachable if we're using GCC 7 or clang versions 6 + // through 10 (note: gem5 does not support GCC versions older than + // GCC 7 or clang versions older than clang 6.0 as they do not + // support the C++17 standard). + // If we're using GCC 7 or clang versions 6 through 10, we need to use + // . #include namespace std { namespace filesystem = experimental::filesystem; diff --git a/src/mem/shared_memory_server.cc b/src/mem/shared_memory_server.cc index f99655c475..a4305d0e11 100644 --- a/src/mem/shared_memory_server.cc +++ b/src/mem/shared_memory_server.cc @@ -39,13 +39,17 @@ #include #include #include -#if (defined(__GNUC__) && (__GNUC__ >= 8)) || defined(__clang__) + +// check if filesystem library is available +#if defined(__cpp_lib_filesystem) || __has_include() #include #else - // This is only reachable if we're using GCC 7 (note: gem5 does not support - // GCC versions older than GCC 7 as they do not support the C++17 - // standard). - // If we're using GCC 7, we need to use . + // This is only reachable if we're using GCC 7 or clang versions 6 + // through 10 (note: gem5 does not support GCC versions older than + // GCC 7 or clang versions older than clang 6.0 as they do not + // support the C++17 standard). + // If we're using GCC 7 or clang versions 6 through 10, we need to use + // . #include namespace std { namespace filesystem = experimental::filesystem;