Skip to content

Commit 8efb225

Browse files
fumitohclaude
andauthored
Suppress C4251 warnings in DLL build (#5)
Inject `add_compile_options(/wd4251)` into cmake/Platform.cmake during patching. C4251 fires for every class member using STL types in a DLL-exported class; with CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON these warnings are harmless noise that drowns out real diagnostics. https://claude.ai/code/session_012RnYmE4NKFQ4NjtbkQANzF Co-authored-by: Claude <noreply@anthropic.com>
1 parent e30ab40 commit 8efb225

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

scripts/Build-QuantLibDLL.ps1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
Upstream QuantLib blocks DLL builds on MSVC with a FATAL_ERROR. This script
1111
applies seven patches to enable DLL builds:
1212
1. cmake/Platform.cmake - Remove FATAL_ERROR blocking DLL builds
13+
and suppress C4251 warnings
1314
2. ql/CMakeLists.txt - Add RUNTIME DESTINATION for DLL install
1415
3. ql/qldefines.hpp.cfg - Inject QL_EXPORT/QL_IMPORT_ONLY macros
1516
4. normaldistribution.hpp - Annotate classes with QL_EXPORT
@@ -115,7 +116,7 @@ $PlatformCmake = "$QLSrcDir\cmake\Platform.cmake"
115116
$original = Get-Content $PlatformCmake -Raw
116117
$patched = $original -replace `
117118
'message\(FATAL_ERROR\s*\r?\n\s*"Shared library \(DLL\) builds for QuantLib on MSVC are not supported"\)', `
118-
'# Patched: DLL build enabled (FATAL_ERROR removed by QuantLib-DLL)'
119+
"# Patched: DLL build enabled (FATAL_ERROR removed by QuantLib-DLL)`nadd_compile_options(/wd4251) # Suppress C4251: STL types in DLL-exported class members"
119120
if ($patched -eq $original) {
120121
Write-Warning "Platform.cmake patch pattern did not match - file may have changed or already patched"
121122
Select-String -Path $PlatformCmake -Pattern "FATAL_ERROR|BUILD_SHARED|EXPORT_ALL|Patched" | Write-Host

0 commit comments

Comments
 (0)