From a99d84e65f3641c415c4a5a6ed8fb8d5455221bd Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:14:48 -0600 Subject: [PATCH 01/15] git submodule add https://github.com/externpro/externpro .devcontainer --- .devcontainer | 1 + .gitmodules | 3 +++ 2 files changed, 4 insertions(+) create mode 160000 .devcontainer diff --git a/.devcontainer b/.devcontainer new file mode 160000 index 0000000000..97db0d6b7d --- /dev/null +++ b/.devcontainer @@ -0,0 +1 @@ +Subproject commit 97db0d6b7d00d8f33e52e646a1aef1395fa58931 diff --git a/.gitmodules b/.gitmodules index 5e41f7c975..8612e8ad70 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "thirdparty/gtest"] path = thirdparty/gtest url = https://github.com/google/googletest.git +[submodule ".devcontainer"] + path = .devcontainer + url = https://github.com/externpro/externpro From 05b1188ad1766372f731cc31a4b03f1540072383 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:21:08 -0600 Subject: [PATCH 02/15] docker-compose links --- docker-compose.sh | 1 + docker-compose.yml | 1 + 2 files changed, 2 insertions(+) create mode 120000 docker-compose.sh create mode 120000 docker-compose.yml diff --git a/docker-compose.sh b/docker-compose.sh new file mode 120000 index 0000000000..85f182f0be --- /dev/null +++ b/docker-compose.sh @@ -0,0 +1 @@ +.devcontainer/compose.pro.sh \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 120000 index 0000000000..46c1f8918f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1 @@ +.devcontainer/compose.bld.yml \ No newline at end of file From cbba56d1c4029afc3d9b394fea1fbf493f315a65 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:23:47 -0600 Subject: [PATCH 03/15] gitattributes: CMakePresets .json as text, not binary --- .gitattributes | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.gitattributes b/.gitattributes index 6f598bb7f9..fa97c8d066 100644 --- a/.gitattributes +++ b/.gitattributes @@ -19,4 +19,9 @@ Dockerfile text # Denote all files that are truly binary and should not be modified. *.png binary *.jpg binary -*.json binary \ No newline at end of file +bin/**/*.json binary +library.json binary +package.json binary + +# Exceptions for JSON files that should be treated as text +CMakePresets*.json text eol=lf From 8d9b9501734edf0155ed93a15677005490e8aab5 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:24:22 -0600 Subject: [PATCH 04/15] add CMakePresets cp .devcontainer/cmake/presets/CMakePresets* . --- CMakePresets.json | 8 ++++++++ CMakePresetsBase.json | 16 ++++++++++++++++ 2 files changed, 24 insertions(+) create mode 100644 CMakePresets.json create mode 100644 CMakePresetsBase.json diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000000..f82cfdd2cf --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,8 @@ +{ + "version": 8, + "include": [ + ".devcontainer/cmake/presets/xpLinuxNinja.json", + ".devcontainer/cmake/presets/xpDarwinNinja.json", + ".devcontainer/cmake/presets/xpWindowsVs2022.json" + ] +} diff --git a/CMakePresetsBase.json b/CMakePresetsBase.json new file mode 100644 index 0000000000..085cdc3e31 --- /dev/null +++ b/CMakePresetsBase.json @@ -0,0 +1,16 @@ +{ + "version": 8, + "configurePresets": [ + { + "name": "config-base", + "hidden": true, + "binaryDir": "${sourceDir}/_bld-${presetName}" + } + ], + "buildPresets": [ + { + "name": "build-base", + "hidden": true + } + ] +} From a2d836097b36b66f1c230115728137b1f65f4f92 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:25:26 -0600 Subject: [PATCH 05/15] gitignore: add externpro ignores --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 5932e82c21..e5ecd59830 100644 --- a/.gitignore +++ b/.gitignore @@ -25,5 +25,10 @@ Doxyfile.zh-cn DartConfiguration.tcl *.nupkg +# externpro +.env +_bld*/ +docker-compose.override.yml + # Files created by OS *.DS_Store From ffd559e547bd7d0c7a85ec8c85d1ca96345cc1f9 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:26:14 -0600 Subject: [PATCH 06/15] externpro github/workflows @25.05.2 cp .devcontainer/.github/wf-templates/xp*.yml .github/workflows --- .github/workflows/xpbuild.yml | 30 ++++++++++++++++++++++++++++++ .github/workflows/xprelease.yml | 20 ++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/xpbuild.yml create mode 100644 .github/workflows/xprelease.yml diff --git a/.github/workflows/xpbuild.yml b/.github/workflows/xpbuild.yml new file mode 100644 index 0000000000..f0192ca9aa --- /dev/null +++ b/.github/workflows/xpbuild.yml @@ -0,0 +1,30 @@ +name: Build +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + workflow_dispatch: +jobs: + linux: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2 + with: + cmake-workflow-preset: Linux + runon: ubuntu-latest + secrets: inherit + linux-arm64: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2 + with: + cmake-workflow-preset: Linux + runon: ubuntu-24.04-arm + secrets: inherit + macos: + uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.2 + with: + cmake-workflow-preset: Darwin + secrets: inherit + windows: + uses: externpro/externpro/.github/workflows/build-windows.yml@25.05.2 + with: + cmake-workflow-preset: Windows + secrets: inherit diff --git a/.github/workflows/xprelease.yml b/.github/workflows/xprelease.yml new file mode 100644 index 0000000000..273199e97d --- /dev/null +++ b/.github/workflows/xprelease.yml @@ -0,0 +1,20 @@ +name: Release +on: + workflow_dispatch: + inputs: + workflow_run_url: + description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)' + required: true + type: string +jobs: + # Upload build artifacts as release assets + release-from-build: + uses: externpro/externpro/.github/workflows/release-from-build.yml@25.05.2 + with: + workflow_run_url: ${{ github.event.inputs.workflow_run_url }} + artifact_pattern: "*.tar.xz" + permissions: + contents: write + id-token: write + attestations: write + secrets: inherit From 7ecf411f430f8bb16a88b646ae7f3ce21a9235a1 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:27:09 -0600 Subject: [PATCH 07/15] CMakePresetsBase: add cacheVariables XP_NAMESPACE --- CMakePresetsBase.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakePresetsBase.json b/CMakePresetsBase.json index 085cdc3e31..4489d79c34 100644 --- a/CMakePresetsBase.json +++ b/CMakePresetsBase.json @@ -4,7 +4,10 @@ { "name": "config-base", "hidden": true, - "binaryDir": "${sourceDir}/_bld-${presetName}" + "binaryDir": "${sourceDir}/_bld-${presetName}", + "cacheVariables": { + "XP_NAMESPACE": "xpro" + } } ], "buildPresets": [ From 63c6a47168bb28d9d169bdaaf67bba3f4cf8cc2e Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:29:27 -0600 Subject: [PATCH 08/15] xpbuild: cmake-workflow-preset Release --- .github/workflows/xpbuild.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/xpbuild.yml b/.github/workflows/xpbuild.yml index f0192ca9aa..b9166a830e 100644 --- a/.github/workflows/xpbuild.yml +++ b/.github/workflows/xpbuild.yml @@ -9,22 +9,22 @@ jobs: linux: uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2 with: - cmake-workflow-preset: Linux + cmake-workflow-preset: LinuxRelease runon: ubuntu-latest secrets: inherit linux-arm64: uses: externpro/externpro/.github/workflows/build-linux.yml@25.05.2 with: - cmake-workflow-preset: Linux + cmake-workflow-preset: LinuxRelease runon: ubuntu-24.04-arm secrets: inherit macos: uses: externpro/externpro/.github/workflows/build-macos.yml@25.05.2 with: - cmake-workflow-preset: Darwin + cmake-workflow-preset: DarwinRelease secrets: inherit windows: uses: externpro/externpro/.github/workflows/build-windows.yml@25.05.2 with: - cmake-workflow-preset: Windows + cmake-workflow-preset: WindowsRelease secrets: inherit From eec40e5f3eea90ef8081fc1e9e3cbf6923c916f4 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 16:30:41 -0600 Subject: [PATCH 09/15] externpro dependency provider --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index be860c93d7..b0d1014048 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.5) +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake) SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) set(LIB_MAJOR_VERSION "1") From f5c3687048ddba69ce9d1ef2fabb47191bf48cf9 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 21:03:39 -0600 Subject: [PATCH 10/15] CMakeLists.txt: include and use GNUInstallDirs --- CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b0d1014048..f2368fa13c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VE PROJECT(RapidJSON VERSION "${LIB_VERSION_STRING}" LANGUAGES CXX) +include(GNUInstallDirs) + # compile in release with debug info mode by default if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE) @@ -145,16 +147,13 @@ elseif (CMAKE_CXX_COMPILER_ID MATCHES "XL") endif() #add extra search paths for libraries and includes -SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "The directory the headers are installed in") -SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE STRING "Directory where lib will install") -SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}" CACHE PATH "Path to the documentation") - -IF(UNIX OR CYGWIN) - SET(_CMAKE_INSTALL_DIR "${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME}") -ELSEIF(WIN32) - SET(_CMAKE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/cmake") -ENDIF() -SET(CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" CACHE PATH "The directory cmake files are installed in") +SET(INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}" CACHE PATH "The directory the headers are installed in") +SET(LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}" CACHE STRING "Directory where lib will install") +SET(DOC_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/doc/${PROJECT_NAME}" CACHE PATH "Path to the documentation") +if(NOT DEFINED XP_INSTALL_CMAKEDIR) + set(XP_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/cmake") +endif() +SET(CMAKE_INSTALL_DIR "${XP_INSTALL_CMAKEDIR}" CACHE PATH "The directory cmake files are installed in") include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) @@ -231,10 +230,10 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}ConfigVersion.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake @ONLY) # ... for the install tree -SET( CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PROJECT_NAME} ) +SET( CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DIR}" ) FILE( RELATIVE_PATH REL_INCLUDE_DIR "${CMAKECONFIG_INSTALL_DIR}" - "${CMAKE_INSTALL_PREFIX}/include" ) + "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}" ) SET( ${PROJECT_NAME}_INCLUDE_DIR "\${${PROJECT_NAME}_CMAKE_DIR}/${REL_INCLUDE_DIR}" ) SET( CONFIG_SOURCE_DIR ) From 61b8d888d6f204babf754652e2d3e71cb84d3cc7 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 21:04:26 -0600 Subject: [PATCH 11/15] cmake_minimum_required 3.5...3.31 --- CMakeLists.txt | 2 +- example/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f2368fa13c..24327dca59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.5) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5...3.31) set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake) SET(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules) diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt index 9f53c9aadc..0d5908c86d 100644 --- a/example/CMakeLists.txt +++ b/example/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8) +cmake_minimum_required(VERSION 3.5...3.31) if(POLICY CMP0054) cmake_policy(SET CMP0054 NEW) From 3c83f206ee2a68bee1f591619b39a5b6a3d89d8a Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 21:10:33 -0600 Subject: [PATCH 12/15] externpro devel package --- CMakeLists.txt | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24327dca59..dd66a822d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ set(LIB_VERSION_STRING "${LIB_MAJOR_VERSION}.${LIB_MINOR_VERSION}.${LIB_PATCH_VE PROJECT(RapidJSON VERSION "${LIB_VERSION_STRING}" LANGUAGES CXX) include(GNUInstallDirs) +include(xpflags) # compile in release with debug info mode by default if(NOT CMAKE_BUILD_TYPE) @@ -157,6 +158,22 @@ SET(CMAKE_INSTALL_DIR "${XP_INSTALL_CMAKEDIR}" CACHE PATH "The directory cmake f include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) +function(callPackageDevel) + set(lib ${PROJECT_NAME}) + string(PREPEND lib ${XP_NAMESPACE}::) + string(TOLOWER ${PROJECT_NAME} CMAKE_PROJECT_NAME) + xpPackageDevel(TARGETS_FILE ${targetsFile} LIBRARIES ${lib}) +endfunction() + +set(targetsFile ${PROJECT_NAME}-targets) +if(DEFINED XP_NAMESPACE) + set(nameSpace NAMESPACE ${XP_NAMESPACE}::) + callPackageDevel() + set(RAPIDJSON_COMPONENT devel) +else() + set(RAPIDJSON_COMPONENT dev) +endif() + if(RAPIDJSON_BUILD_DOC) add_subdirectory(doc) endif() @@ -193,13 +210,13 @@ install(FILES readme.md COMPONENT doc) # Add an interface target to export it -add_library(RapidJSON INTERFACE) +add_library(${PROJECT_NAME} INTERFACE) -target_include_directories(RapidJSON INTERFACE $) +target_include_directories(${PROJECT_NAME} INTERFACE $) install(DIRECTORY include/rapidjson DESTINATION "${INCLUDE_INSTALL_DIR}" - COMPONENT dev) + COMPONENT ${RAPIDJSON_COMPONENT}) install(DIRECTORY example/ DESTINATION "${DOC_INSTALL_DIR}/examples" @@ -252,6 +269,6 @@ IF(CMAKE_INSTALL_DIR) DESTINATION "${CMAKE_INSTALL_DIR}" COMPONENT dev) - INSTALL(TARGETS RapidJSON EXPORT RapidJSON-targets) - INSTALL(EXPORT RapidJSON-targets DESTINATION ${CMAKE_INSTALL_DIR}) + INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${targetsFile} COMPONENT ${RAPIDJSON_COMPONENT}) + INSTALL(EXPORT ${targetsFile} DESTINATION ${CMAKE_INSTALL_DIR} ${nameSpace} COMPONENT ${RAPIDJSON_COMPONENT}) ENDIF() From 9650ba45d45704563599dbd12f372f3c6c235195 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 21:11:37 -0600 Subject: [PATCH 13/15] cmake 3.31 add_custom_command requires one of three keywords * see docs https://cmake.org/cmake/help/v3.31/command/add_custom_command.html#build-events * policy CMP0175 https://cmake.org/cmake/help/latest/policy/CMP0175.html * Previously, if none were given, POST_BUILD was assumed --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd66a822d5..d651d203bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -179,7 +179,7 @@ if(RAPIDJSON_BUILD_DOC) endif() add_custom_target(travis_doc) -add_custom_command(TARGET travis_doc +add_custom_command(TARGET travis_doc POST_BUILD COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/travis-doxygen.sh) if(RAPIDJSON_BUILD_EXAMPLES) From 45ee7f6a3027351632d0d340e0af94915e668963 Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 21:13:04 -0600 Subject: [PATCH 14/15] use googletest devel package instead of out-of-date GTestSrc --- test/CMakeLists.txt | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 11c1b04c7d..7f407e06b6 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,4 +1,17 @@ -find_package(GTestSrc) +if(COMMAND xpFindPkg) + xpFindPkg(PKGS googletest) + enable_testing() + get_target_property(GTEST_INCLUDE_DIR xpro::gtest INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${GTEST_INCLUDE_DIR}) + set(TEST_LIBRARIES xpro::gtest xpro::gtest_main) + if(FALSE) # doesn't build with googletest-v1.16.0.1 + add_custom_target(tests ALL) + add_subdirectory(perftest) + add_subdirectory(unittest) + endif() +else() + find_package(GTestSrc) +endif() IF(GTESTSRC_FOUND) enable_testing() From 1aecd0304438cbc92f271b94fa20944180179afe Mon Sep 17 00:00:00 2001 From: Scott M Anderson Date: Wed, 8 Oct 2025 21:15:50 -0600 Subject: [PATCH 15/15] fix compile errors [-Werror,-Wdeprecated-declarations] error: 'sprintf' is deprecated: This function is provided for compatibility reasons only. Due to security concerns inherent in the design of sprintf(3), it is highly recommended that you use snprintf(3) instead. [-Werror,-Wdeprecated-declarations] --- example/jsonx/jsonx.cpp | 10 +++++----- example/tutorial/tutorial.cpp | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/example/jsonx/jsonx.cpp b/example/jsonx/jsonx.cpp index 954aa2b907..b2d72317b5 100644 --- a/example/jsonx/jsonx.cpp +++ b/example/jsonx/jsonx.cpp @@ -34,27 +34,27 @@ class JsonxWriter { bool Int(int i) { char buffer[12]; - return WriteNumberElement(buffer, sprintf(buffer, "%d", i)); + return WriteNumberElement(buffer, snprintf(buffer, sizeof(buffer), "%d", i)); } bool Uint(unsigned i) { char buffer[11]; - return WriteNumberElement(buffer, sprintf(buffer, "%u", i)); + return WriteNumberElement(buffer, snprintf(buffer, sizeof(buffer), "%u", i)); } bool Int64(int64_t i) { char buffer[21]; - return WriteNumberElement(buffer, sprintf(buffer, "%" PRId64, i)); + return WriteNumberElement(buffer, snprintf(buffer, sizeof(buffer), "%" PRId64, i)); } bool Uint64(uint64_t i) { char buffer[21]; - return WriteNumberElement(buffer, sprintf(buffer, "%" PRIu64, i)); + return WriteNumberElement(buffer, snprintf(buffer, sizeof(buffer), "%" PRIu64, i)); } bool Double(double d) { char buffer[30]; - return WriteNumberElement(buffer, sprintf(buffer, "%.17g", d)); + return WriteNumberElement(buffer, snprintf(buffer, sizeof(buffer), "%.17g", d)); } bool RawNumber(const char* str, SizeType length, bool) { diff --git a/example/tutorial/tutorial.cpp b/example/tutorial/tutorial.cpp index d6021c6689..6e10d9d33d 100644 --- a/example/tutorial/tutorial.cpp +++ b/example/tutorial/tutorial.cpp @@ -122,7 +122,7 @@ int main(int, char*[]) { Value author; { char buffer2[10]; - int len = sprintf(buffer2, "%s %s", "Milo", "Yip"); // synthetic example of dynamically created string. + int len = snprintf(buffer2, sizeof(buffer2), "%s %s", "Milo", "Yip"); // synthetic example of dynamically created string. author.SetString(buffer2, static_cast(len), document.GetAllocator()); // Shorter but slower version: