Skip to content

Compilation error on Windows with MSVC 19.41.34120.0 #3935

Closed

Description

@magnushakansson

Describe the bug

When building with following parameters to CMake:

-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>
-DBUILD_ONLY=s3;s3-crt
-DBUILD_SHARED_LIBS=OFF
-DCPP_STANDARD=17
-DCUSTOM_MEMORY_MANAGEMENT=ON
-DENABLE_TESTING=OFF
-DFORCE_SHARED_CRT=OFF
-DAWS_STATIC_MSVC_RUNTIME_LIBRARY=ON

I get:

09:53:34  C:\Jws\qix-pc3-build-ws\build\aws-sdk-cpp\lib\src\aws-cpp-sdk-core\include\smithy\client\schema\JsonTraits.h(24,46): error C2220: the following warning is treated as an error [C:\Jws\qix-pc3-build-ws\build\aws-sdk-cpp\out\x64\src\aws-cpp-sdk-core\aws-cpp-sdk-core.vcxproj]
09:53:34    (compiling source file '../../../../lib/src/aws-cpp-sdk-core/source/smithy/client/schema/TraitKey.cpp')
09:53:34    
09:53:34  C:\Jws\qix-pc3-build-ws\build\aws-sdk-cpp\lib\src\aws-cpp-sdk-core\include\smithy\client\schema\JsonTraits.h(24,46): warning C4275: non dll-interface class 'smithy::schema::TraitKeyBase' used as base for dll-interface class 'smithy::schema::TraitKey<smithy::schema::JsonNameTrait>' [C:\Jws\qix-pc3-build-ws\build\aws-sdk-cpp\out\x64\src\aws-cpp-sdk-core\aws-cpp-sdk-core.vcxproj]
09:53:34    (compiling source file '../../../../lib/src/aws-cpp-sdk-core/source/smithy/client/schema/TraitKey.cpp')
09:53:34        C:\Jws\qix-pc3-build-ws\build\aws-sdk-cpp\lib\src\aws-cpp-sdk-core\include\smithy\client\schema\TraitKey.h(7,18):
09:53:34        see declaration of 'smithy::schema::TraitKeyBase'
09:53:34        C:\Jws\qix-pc3-build-ws\build\aws-sdk-cpp\lib\src\aws-cpp-sdk-core\include\smithy\client\schema\JsonTraits.h(24,46):
09:53:34        see declaration of 'smithy::schema::TraitKey<smithy::schema::JsonNameTrait>'

Regression Issue

  • Select this option if this issue appears to be a regression.

Expected Behavior

It compiled in 1.11.817

Current Behavior

Build with:

-DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>
-DBUILD_ONLY=s3;s3-crt
-DBUILD_SHARED_LIBS=OFF
-DCPP_STANDARD=17
-DCUSTOM_MEMORY_MANAGEMENT=ON
-DENABLE_TESTING=OFF
-DFORCE_SHARED_CRT=OFF
-DAWS_STATIC_MSVC_RUNTIME_LIBRARY=ON

And you get the compilation error.

Reproduction Steps

See above.

Possible Solution

diff --git a/src/aws-cpp-sdk-core/source/smithy/client/schema/TraitKey.cpp b/src/aws-cpp-sdk-core/source/smithy/client/schema/TraitKey.cpp
index dff0c2f99..5ea4b7a27 100644
--- a/src/aws-cpp-sdk-core/source/smithy/client/schema/TraitKey.cpp
+++ b/src/aws-cpp-sdk-core/source/smithy/client/schema/TraitKey.cpp
@@ -22,7 +22,7 @@ const TraitKey<T>& TraitKey<T>::Instance() {
   return instance;
 }
 
-#ifdef _MSC_VER
+#if defined(_MSC_VER) && defined(USE_IMPORT_EXPORT)
 #define SMITHY_TEMPLATE_EXPORT __declspec(dllexport)
 #else
 #define SMITHY_TEMPLATE_EXPORT
-- 
2.49.0

Additional Information/Context

No response

AWS CPP SDK version used

1.11.895

Compiler and Version used

MSVC 19.41.34120.0

Operating System and version

Windows 11

Activity

  1. sbiscigl commented on Sep 22, 2026

    @sbiscigl
    Contributor

    confirmed reproduction and pushing out a fix, thanks for bringing this to our attention!

  2. sbiscigl commented on Sep 23, 2026

    @sbiscigl
    Contributor

    should be merged to main now, and released this afternoon as version 1.11.899. give it try and let me know if you see anymore issues

  3. added
    pending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.
    and removed
    needs-triageThis issue or PR still needs to be triaged.
    on Sep 23, 2026
  4. magnushakansson commented on Sep 24, 2026

    @magnushakansson
    Author

    should be merged to main now, and released this afternoon as version 1.11.899. give it try and let me know if you see anymore issues

    It works well now. Thanks for the quick fix.

  5. github-actions commented on Sep 24, 2026

    @github-actions

    This issue is now closed. Comments on closed issues are hard for our team to see.
    If you need more assistance, please open a new issue that references this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue is a bug.pending-releaseThis issue will be fixed by an approved PR that hasn't been released yet.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions