Skip to content

Free, open-source 3D sculpting for Linux, macOS and Windows: dense meshes, remeshing, painting, built-in AI (image/text to 3D), Send to Unreal, game-ready LODs, Gaussian splats and OpenUSD.

Shader raw literals under MSVC's limit: kMeshFS in two adjacent literals (text byte for byte the same; 15,668 chars on main, the Windows build fails at ~16,380, C2026); ctest raw_literal_size (tools/dev/check_literals.py) fails on any raw literal in src/ over 16,000

islandmedfcd8dbfc31a6
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c0a4c5ff..f5f8ea89 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -742,6 +742,8 @@ if(SCULPTFORGE_BUILD_TESTS)
# every fragment on this branch parses.
add_test(NAME marks COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/check_marks.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) # docs/legal/trademarks.md
+ # No raw string literal in src/ over MSVC's ~16K characters (C2026: only the Windows build would fail).
+ add_test(NAME raw_literal_size COMMAND ${Python3_EXECUTABLE} -I ${CMAKE_CURRENT_SOURCE_DIR}/tools/dev/check_literals.py)
# website/brushes.html #packs matches src/core/BrushPacks.cpp: every brush, its preview and the guide links.
add_test(NAME website_brush_packs COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tools/brush-packs/sync_website.py --check)
# Every interface label has a Spanish and a Traditional Chinese translation (or is a name kept in English,
diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp
index 5429e76f..d6964b7a 100644
--- a/src/render/Renderer.cpp
+++ b/src/render/Renderer.cpp
@@ -406,7 +406,8 @@ vec4 finish(vec3 c) {
#endif
return vec4(g, uAlpha);
}
-// Keep in sync with sf::face groupColor.
+)" // (two literals: MSVC stops at ~16K characters a literal, C2026; tools/dev/check_literals.py)
+R"(// Keep in sync with sf::face groupColor.
vec3 groupColor(uint id) {
uint h = id * 0x9E3779B1u;
h ^= h >> 15;
diff --git a/tools/dev/check_literals.py b/tools/dev/check_literals.py
new file mode 100755
index 00000000..a2c5a606
--- /dev/null
+++ b/tools/dev/check_literals.py
@@ -0,0 +1,44 @@
+#!/usr/bin/env python3
+# SculptForge - open source digital sculpting
+# SPDX-License-Identifier: GPL-3.0-or-later
+"""Fails when a C++ raw string literal in src/ is longer than MSVC accepts in one piece.
+
+MSVC stops at about 16,380 characters a literal (error C2026, "string too big"); Linux and macOS compilers don't, so
+a long shader only breaks the Windows build. Split it into adjacent literals, R"(...)" R"(...)": the compiler joins
+them (up to 64K) and the text stays the same.
+
+ tools/dev/check_literals.py exit 1 if any literal is over LIMIT (ctest raw_literal_size)
+ tools/dev/check_literals.py --list N every literal over N characters, largest first
+"""
+import re
+import sys
+from pathlib import Path
+
+LIMIT = 16000 # (MSVC's ~16,380, with room)
+ROOT = Path(__file__).resolve().parents[2]
+RAW = re.compile(r'R"([^()\\\s]{0,16})\((.*?)\)\1"', re.S)
+
+
+def literals():
+ for path in sorted((ROOT / "src").rglob("*")):
+ if path.suffix not in {".cpp", ".h", ".hpp", ".cc", ".inl"} or not path.is_file():
+ continue
+ text = path.read_text(encoding="utf-8", errors="replace")
+ for m in RAW.finditer(text):
+ yield path.relative_to(ROOT), text.count("\n", 0, m.start()) + 1, len(m.group(2))
+
+
+def main():
+ if len(sys.argv) == 3 and sys.argv[1] == "--list":
+ for path, line, n in sorted(literals(), key=lambda x: -x[2]):
+ if n > int(sys.argv[2]):
+ print(f"{path}:{line}: {n} characters")
+ return 0
+ over = [(p, l, n) for p, l, n in literals() if n > LIMIT]
+ for path, line, n in over:
+ print(f"{path}:{line}: raw string literal of {n} characters, over {LIMIT} (MSVC C2026): split it, R\"(...)\" R\"(...)\"")
+ return 1 if over else 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())