Skip to content

[MSVC] rapidjson failed with error C2065: 'fallthrough': undeclared identifier' on Windows with VS2026 #2404

Open

Description

@QuellaZhang

Hi All,

The MSVC team regularly builds popular open-source projects, including yours, with development versions of the build tools in order to find and fix regressions in the compiler and libraries before they can ship and cause trouble for the world. This also allows us to provide advance notice of breaking changes, which is the case here.

rapidjson failed with error C2065: 'fallthrough': undeclared identifier on Windows with VS2026. This is a new problem, it can be reproduced on 24b5e7a commit on main branch. Could you please help take a look? Thanks in advance!

This is because rapidjson using the __has_cpp_attribute operator, but setting the attribute using the gcc __attribute__ syntax. Reference https://gcc.gnu.org/onlinedocs/cpp/_005f_005fhas_005fattribute.html.

Repro steps:

1. Open VS2026 x64 CMD.
2. git clone https://github.com/Tencent/rapidjson.git C:\gitP\Tencent\rapidjson
3. mkdir C:\gitP\Tencent\rapidjson\build_amd64 && cd C:\gitP\Tencent\rapidjson\build_amd64
4. cmake -G "Visual Studio 18 2026" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.26100.0 -Dgtest_force_shared_crt=TRUE -DCMAKE_POLICY_VERSION_MINIMUM=3.5 ..
5. msbuild /m /p:Platform=x64 /p:Configuration=Release Rapidjson.slnx /t:Rebuild

Build log:

Build.log

Error info:

schemavalidator.cpp
C:\gitP\Tencent\rapidjson\include\rapidjson\internal/regex.h(290): error C2065: 'fallthrough': undeclared identifier
C:\gitP\Tencent\rapidjson\include\rapidjson\internal/regex.h(290): note: the template instantiation context (the oldest one first) is
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(2435): note: while processing the default template argument of 'rapidjson::GenericSchemaValidator '
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(2435): note: see reference to class template instantiation 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>' being compiled
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(830): note: while compiling class template member function 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>::~Schema(void)'
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(1747): note: see the first reference to 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>::~Schema' in 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>::~Schema'
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(845): note: see reference to class template instantiation 'rapidjson::internal::GenericRegex<rapidjson::UTF8<char>,rapidjson::CrtAllocator>' being compiled
C:\gitP\Tencent\rapidjson\include\rapidjson\internal/regex.h(116): note: while compiling class template member function 'rapidjson::internal::GenericRegex<rapidjson::UTF8<char>,rapidjson::CrtAllocator>::GenericRegex(const char *,Allocator *)'
        with
        [
            Allocator=rapidjson::CrtAllocator
        ]
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(1402): note: see the first reference to 'rapidjson::internal::GenericRegex<rapidjson::UTF8<char>,rapidjson::CrtAllocator>::GenericRegex' in 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>::CreatePattern'
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(703): note: see the first reference to 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>::CreatePattern' in 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>::Schema'
C:\gitP\Tencent\rapidjson\include\rapidjson/schema.h(1867): note: see the first reference to 'rapidjson::internal::Schema<rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>>::Schema' in 'rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>::GenericSchemaDocument'
C:\gitP\Tencent\rapidjson\example\schemavalidator\schemavalidator.cpp(161): note: see the first reference to 'rapidjson::GenericSchemaDocument<rapidjson::Value,rapidjson::CrtAllocator>::GenericSchemaDocument' in 'main'
C:\gitP\Tencent\rapidjson\include\rapidjson\internal/regex.h(123): note: see reference to function template instantiation or specialization 'void rapidjson::internal::GenericRegex<rapidjson::UTF8<char>,rapidjson::CrtAllocator>::Parse<rapidjson::GenericStringStream<rapidjson::UTF8<char>>>(rapidjson::internal::DecodedStream<rapidjson::GenericStringStream<rapidjson::UTF8<char>>,Encoding> &)' being compiled
        with
        [
            Encoding=rapidjson::UTF8<char>
        ]
C:\gitP\Tencent\rapidjson\include\rapidjson\internal/regex.h(290): error C3861: '__attribute__': identifier not found

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions