diff --git a/README.md b/README.md index 4b93788f81..59296be0b5 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,9 @@ git_override(module_name = "fory", remote = "https://github.com/apache/fory.git" deps = ["@fory//cpp/fory/serialization:fory_serialization"] ``` +When building C++ with MSVC, enable the conforming preprocessor option +`/Zc:preprocessor`; see the C++ installation guide for setup details. + See the [C++ installation guide](https://fory.apache.org/docs/guide/cpp/#installation) for complete CMake, Bazel, and source-build details. diff --git a/cpp/README.md b/cpp/README.md index 4e7ab89e54..fc1c5d0292 100644 --- a/cpp/README.md +++ b/cpp/README.md @@ -359,11 +359,20 @@ cpp/fory/ - **C++ Standard**: C++17 or later - **Build System**: Bazel 8.2.1+ or CMake 3.16+ +- **MSVC**: configure your build system to pass `/Zc:preprocessor`. ## Building ### With Bazel +When building with MSVC, add the conforming preprocessor option to your Bazel +configuration: + +```bazel +# .bazelrc +build --cxxopt=/Zc:preprocessor +``` + ```bash # Build all projects bazel build //cpp/... @@ -377,6 +386,15 @@ bazel test $(bazel query //cpp/fory/serialization/...) ### With CMake +When building with MSVC, add `/Zc:preprocessor` before bringing Fory into the +build: + +```cmake +if(MSVC) + add_compile_options(/Zc:preprocessor) +endif() +``` + ```bash mkdir build && cd build cmake .. diff --git a/docs/guide/cpp/index.md b/docs/guide/cpp/index.md index 537ef9fd17..fba62ef411 100644 --- a/docs/guide/cpp/index.md +++ b/docs/guide/cpp/index.md @@ -42,6 +42,9 @@ The C++ implementation supports both CMake and Bazel build systems. - CMake 3.16+ (for CMake build) or Bazel 8+ (for Bazel build) - C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+) +When building with MSVC, configure your build system to pass +`/Zc:preprocessor`. + ### Using CMake (Recommended) The easiest way to use Fory is with CMake's `FetchContent` module: @@ -107,6 +110,14 @@ cc_binary( ) ``` +When building with MSVC, add the conforming preprocessor option to your Bazel +configuration: + +```bazel +# .bazelrc +build --cxxopt=/Zc:preprocessor +``` + Then build and run: ```bash