awslabs / aws-crt-cpp

C++ wrapper around the aws-c-* libraries. Provides Cross-Platform Transport Protocols and SSL/TLS implementations for C++.
Apache License 2.0
76 stars 67 forks source link

[MSVC] Compile error in StringView.h with c++20 or later #655

Closed NEIL-smtg closed 2 months ago

NEIL-smtg commented 2 months ago

Describe the bug

I work on MSVC compiler testing, and we regularly build popular open-source project, with development builds of MSVC in order to find and fix regressions.

Recently, when we are building OSQuery, which used aws-crt-cpp as one of its libraries, it encountered error C3878 and C2760 in StringView.h L861:

Note: OSQuery is using c2d6ffa, which is a commit from 3 years ago. Hence the line that causing error might be different with the latest commit.

Expected Behavior

It compiles

Current Behavior

C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(856): error C3878: syntax error: unexpected token ',' following 'simple-type-specifier'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(856): note: missing one of: ( { ?
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(856): error C3878: syntax error: unexpected token ',' following 'simple-declaration'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(856): note: error recovery skipped: ','
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(856): error C2760: syntax error: '>' was unexpected here; expected 'declaration'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): error C3878: syntax error: unexpected token ',' following 'simple-type-specifier'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): note: missing one of: ( { ?
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): error C2760: syntax error: ',' was unexpected here; expected ';'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): error C3878: syntax error: unexpected token ',' following 'jump-statement'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): note: error recovery skipped: ','
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): error C2760: syntax error: '>>' was unexpected here; expected 'declaration'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): error C2760: syntax error: ')' was unexpected here; expected 'expression'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): error C2760: syntax error: ')' was unexpected here; expected ';'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): error C3878: syntax error: unexpected token ')' following 'expression-statement'
C:\gitP\facebook\osquery\libraries\cmake\source\aws-sdk-cpp\src\aws-crt-cpp\include\aws/crt/StringView.h(857): note: error recovery skipped: ')'

Reproduction Steps

  1. Download the preprocessed file: Api.txt
  2. Open x64 Native Windows Command prompt
  3. CL /c /TP /EHsc /std:c++20 Api.txt

Possible Solution

No response

Additional Information/Context

OSQuery build log: os.log

aws-crt-cpp version used

.

Compiler and version used

MSVC 19.42.34325.97

Operating System and version

Windows 11

graebm commented 2 months ago

Fixed by https://github.com/awslabs/aws-crt-cpp/pull/659