Skip to content

Fix C1021 fatal error when building DataSQLite with POCO_SQLITE_UNBUNDLED on MSVC - #5336

Merged
matejk merged 1 commit into
pocoproject:mainfrom
uilianries:fix/win-pragma-warning
Apr 23, 2026
Merged

Fix C1021 fatal error when building DataSQLite with POCO_SQLITE_UNBUNDLED on MSVC#5336
matejk merged 1 commit into
pocoproject:mainfrom
uilianries:fix/win-pragma-warning

Conversation

@uilianries

Copy link
Copy Markdown
Contributor

Hello Poco maintainers! 👋

Summary

When building Poco 1.15.2 on Conan via PR conan-io/conan-center-index#29722, a new compilation error came when building on Windows with MSVC and POCO_UNBUNDLED=ON:

[603/669] Building CXX object Data\SQLite\CMakeFiles\DataSQLite.dir\src\Utility.cpp.obj
FAILED: Data/SQLite/CMakeFiles/DataSQLite.dir/src/Utility.cpp.obj 
C:\PROGRA~1\MICROS~2\2022\COMMUN~1\VC\Tools\MSVC\1444~1.352\bin\Hostx64\x64\cl.exe  /nologo /TP -DPOCO_CMAKE -DPOCO_DLL -DPOCO_ENABLE_FASTLOGGER -DPOCO_NO_AUTOMATIC_LIBS=1 -DPOCO_OS_FAMILY_WINDOWS -DPOCO_SQLITE_UNBUNDLED -DPOCO_UNBUNDLED -DSQLITE_API=__declspec(dllimport) -DSQLITE_THREADSAFE=1 -DSQLParser_EXPORTS -DSQLite_EXPORTS -DUNICODE -DXML_DTD=1 -D_UNICODE -IC:\j\29722-6\b\pocoeaefe95cf9364\b\src\Data\SQLite\include -IC:\j\29722-6\b\pocoeaefe95cf9364\b\src\Data\SQLite\src -IC:\j\29722-6\b\pocoeaefe95cf9364\b\src\Data\include -IC:\j\29722-6\b\pocoeaefe95cf9364\b\src\Data\src -IC:\j\29722-6\b\pocoeaefe95cf9364\b\src\Foundation\include -IC:\j\29722-6\b\pocoeaefe95cf9364\b\src\dependencies\tessil\include -IC:\j\29722-6\b\pocoeaefe95cf9364\b\src\dependencies\quill\include -external:IC:\j\29722-6\sqlita6b10382efd94\p\include -external:W0 /DWIN32 /D_WINDOWS /EHsc /Zc:__cplusplus /O2 /Ob2 /DNDEBUG -std:c++20 -MD /showIncludes /FoData\SQLite\CMakeFiles\DataSQLite.dir\src\Utility.cpp.obj /FdData\SQLite\CMakeFiles\DataSQLite.dir\ /FS -c C:\j\29722-6\b\pocoeaefe95cf9364\b\src\Data\SQLite\src\Utility.cpp
C:\j\29722-6\b\pocoeaefe95cf9364\b\src\Data\SQLite\src\Utility.cpp(43): fatal error C1021: invalid preprocessor command 'warning'

Full build log: https://c3i.jfrog.io/artifactory/cci-build-logs/cci/prod/PR-29722/6/package_build_logs/build_log_poco_1_15_2_0adc2f8480994b99f01861be3ca8abd7_7c1918cef109f6ba5d4f8f80693ced80922aa350.txt

Note that it was not seen for version 1.14.2, which is distributed/built by Conan. It could be related to #4996, as we started to see it after 1.15.z only.

Cause of the Problem

MSVC does not support the #warning preprocessor directive (it is a GCC/Clang extension). When building with -DPOCO_SQLITE_UNBUNDLED on Windows, the compiler emits a fatal error:

fatal error C1021: invalid preprocessor command 'warning'

References:

Proposed Fix

#pragma message(...) is supported by MSVC, GCC, and Clang, making it a portable drop-in replacement. The message text is preserved, prefixed with WARNING: to retain its intent.

I applied the proposed patch on Conan side, so we can validate it on the CI as well:

Affected configuration

  • Platform: Windows
  • Poco version: 1.15.2 (probably 1.15.0 and 1.15.1 as well)
  • Compiler: Visual Studio 17 2022 - MSVC 19.44.35213.0
  • Build flag: -DPOCO_SQLITE_UNBUNDLED

The MSVC compiler in newer version does not support the preprocessor
\#warning, instead, it should use \#pragma message. That alternative
is compatible with both GCC and Clang compilers.

Signed-off-by: Uilian Ries <uilianries@gmail.com>
@aleks-f aleks-f added this to the Release 1.15.3 milestone Apr 23, 2026
@matejk
matejk merged commit 49af400 into pocoproject:main Apr 23, 2026
44 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants