Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Add `OPENVINO_CPP_VER_AT_LEAST_23` macro support and simplify filesystem includes (#31080)

Arseniy Obolenskiy931ccef0f641
diff --git a/src/common/util/include/openvino/util/cpp_version.hpp b/src/common/util/include/openvino/util/cpp_version.hpp
index b250df6a38b..31a87f24b43 100644
--- a/src/common/util/include/openvino/util/cpp_version.hpp
+++ b/src/common/util/include/openvino/util/cpp_version.hpp
@@ -15,6 +15,9 @@
# define OPENVINO_CPP_VER_AT_LEAST_17
# if __cplusplus >= 202002L
# define OPENVINO_CPP_VER_AT_LEAST_20
+# if __cplusplus >= 202302L
+# define OPENVINO_CPP_VER_AT_LEAST_23
+# endif
# endif
# endif
# endif
@@ -28,6 +31,9 @@
# define OPENVINO_CPP_VER_AT_LEAST_17
# if _MSVC_LANG >= 202002L
# define OPENVINO_CPP_VER_AT_LEAST_20
+# if _MSVC_LANG >= 202302L
+# define OPENVINO_CPP_VER_AT_LEAST_23
+# endif
# endif
# endif
# endif
diff --git a/src/common/util/include/openvino/util/file_path.hpp b/src/common/util/include/openvino/util/file_path.hpp
index f5816956d68..680f5de8f09 100644
--- a/src/common/util/include/openvino/util/file_path.hpp
+++ b/src/common/util/include/openvino/util/file_path.hpp
@@ -5,34 +5,15 @@
#pragma once
#include <cstdio>
-
-#include "openvino/util/filesystem.hpp"
+#include <filesystem>
namespace ov::util {
-#if defined(OPENVINO_HAS_FILESYSTEM)
// There are known issues with usage of std::filesystem::path unicode represenataion:
// * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95048
// * https://stackoverflow.com/questions/58521857/cross-platform-way-to-handle-stdstring-stdwstring-with-stdfilesystempath
// Working compiler versions has been designated with godbolt.
using Path = std::filesystem::path;
-#elif defined(OPENVINO_HAS_EXP_FILESYSTEM)
-// Known issues:
-// * error C2280: 'std::u32string std::experimental::filesystem::v1::path::u32string(void) const': attempting to
-// * filesystem error: Cannot convert character sequence: Invalid in or incomplete multibyte or wide character
-
-///
-/// @typedef Path
-/// @brief Alias for std::experimental::filesystem::path.
-///
-/// This alias is used to simplify the usage of filesystem paths.
-///
-/// @note The experimental version of std::filesystem::path may not support all features correctly.
-/// It is recommended to use this alias with caution and consider upgrading to C++17 or higher
-/// for full support of std::filesystem::path.
-///
-using Path = std::experimental::filesystem::path;
-#endif
#if !defined(__GNUC__) || (__GNUC__ > 12 || __GNUC__ == 12 && __GNUC_MINOR__ >= 3)
# define GCC_NOT_USED_OR_VER_AT_LEAST_12_3
diff --git a/src/common/util/include/openvino/util/filesystem.hpp b/src/common/util/include/openvino/util/filesystem.hpp
deleted file mode 100644
index 3ff5be2e299..00000000000
--- a/src/common/util/include/openvino/util/filesystem.hpp
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (C) 2018-2025 Intel Corporation
-// SPDX-License-Identifier: Apache-2.0
-//
-
-#pragma once
-
-#include "openvino/util/cpp_version.hpp"
-
-#if defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_17)
-# define OPENVINO_HAS_FILESYSTEM
-#elif defined(_MSC_VER) && defined(OPENVINO_CPP_VER_AT_LEAST_11)
-# define OPENVINO_HAS_EXP_FILESYSTEM
-# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
-# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM
-#elif defined(__has_include)
-# if defined(OPENVINO_CPP_VER_AT_LEAST_17) && (__has_include(<filesystem>))
-# define OPENVINO_HAS_FILESYSTEM
-# elif defined(OPENVINO_CPP_VER_AT_LEAST_11) && (__has_include(<experimental/filesystem>))
-# define OPENVINO_HAS_EXP_FILESYSTEM
-# define _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING
-# define _LIBCPP_NO_EXPERIMENTAL_DEPRECATION_WARNING_FILESYSTEM
-# endif
-#endif
-
-#if defined(OPENVINO_HAS_FILESYSTEM)
-# include <filesystem>
-#elif defined(OPENVINO_HAS_EXP_FILESYSTEM)
-# include <experimental/filesystem>
-#else
-# error "Neither #include <filesystem> nor #include <experimental/filesystem> is available."
-#endif
diff --git a/src/core/include/openvino/core/visibility.hpp b/src/core/include/openvino/core/visibility.hpp
index 2e8f6490a41..89a2059698b 100644
--- a/src/core/include/openvino/core/visibility.hpp
+++ b/src/core/include/openvino/core/visibility.hpp
@@ -87,6 +87,9 @@
# define OPENVINO_CPP_VER_AT_LEAST_17
# if __cplusplus >= 202002L
# define OPENVINO_CPP_VER_AT_LEAST_20
+# if __cplusplus >= 202302L
+# define OPENVINO_CPP_VER_AT_LEAST_23
+# endif
# endif
# endif
# endif
@@ -100,6 +103,9 @@
# define OPENVINO_CPP_VER_AT_LEAST_17
# if _MSVC_LANG >= 202002L
# define OPENVINO_CPP_VER_AT_LEAST_20
+# if _MSVC_LANG >= 202302L
+# define OPENVINO_CPP_VER_AT_LEAST_23
+# endif
# endif
# endif
# endif
diff --git a/src/core/tests/file_util.cpp b/src/core/tests/file_util.cpp
index 459555cf518..c2da68bf12b 100644
--- a/src/core/tests/file_util.cpp
+++ b/src/core/tests/file_util.cpp
@@ -12,6 +12,7 @@
#include <string_view>
#include <vector>
+#include "openvino/core/visibility.hpp"
#include "openvino/util/file_path.hpp"
using namespace std;
diff --git a/src/plugins/intel_cpu/src/utils/cpp/to_underlying.hpp b/src/plugins/intel_cpu/src/utils/cpp/to_underlying.hpp
index 613aede4925..f51db837ff2 100644
--- a/src/plugins/intel_cpu/src/utils/cpp/to_underlying.hpp
+++ b/src/plugins/intel_cpu/src/utils/cpp/to_underlying.hpp
@@ -7,7 +7,7 @@
namespace ov::intel_cpu {
-#ifdef OPENVINO_CPP_23_VER
+#ifdef OPENVINO_CPP_VER_AT_LEAST_23
using to_underlying = std::to_underlying;
#else
// implementation of C++23 std::to_underlying