Comments (8)
This is a flexible array member, a perfectly fine part of standard C99:
As a special case, the last element of a structure with more than one named member may
have an incomplete array type; this is called a flexible array member.
The issue here is with Visual Studio 2022 not being C99-compliant
from mbedtls.
AFAIK Visual Studio does support flexible array members, and it didn't complain about them in our CI builds which go back to VS2013. Please make sure that you compile in a C99 or C11 mode, not C90 mode.
from mbedtls.
Microsoft also says:
This causes a Level-2 warning when a C++ file is compiled and a Level-4 warning when a C file is compiled.
CI should not complain because of the level 4.
For me this was compiled as a part of C++ solution, and I usually prefer to see more warnings.
Closing the issue since this is valid in C99 and not an MS extension.
from mbedtls.
We're getting this issue on Clang as a library user.
/opt/homebrew/include/psa/crypto_struct.h:229:13: fatal error: flexible array members are a C99 feature [-Wc99-extensions]
uint8_t data[];
^
1 error generated.
This C feature was not included when C99 was merged into the C++ spec in C++11. This means if you are using mbedTLS from a C++ project you need to compile with non-portable vendor extensions to use mbedTLS.
https://en.wikipedia.org/wiki/Flexible_array_member#Availability
from mbedtls.
Hmm, these definitions should be inside extern "C"
to avoid exactly this
from mbedtls.
extern "C" and extern "C++" function declarations
Literally, it seems the declaration allows C calling convention, not C syntax or language extenstions.
from mbedtls.
This C feature was not included when C99 was merged into the C++ spec in C++11.
Ah, that is a problem that I was no aware of.
https://en.wikipedia.org/wiki/Flexible_array_member#Availability
Flexible array members are not officially part of C++
Hmm, is this up-to-date? https://en.cppreference.com/w/cpp/language/array (which is usually accurate in my experience, but I'm a C programmer, not a C++ programmer) suggests that uint8_t data[];
is syntactically valid, and the section “Arrays of unknown bound” suggests that it's a valid incomplete type. Can an experienced C++ programmer please let me know what the situation is here? How do C++ programs typically consume C headers that define structures with flexible array members?
from mbedtls.
I've filed a separate issue to track the C++ incompatibility introduced in 3.6: #9020
from mbedtls.
Related Issues (20)
- Replace `MBEDTLS_MD_CAN_SHA512` with its `PSA_WANT` counterpartart
- Replace `MBEDTLS_MD_CAN_SHA3_*` with its `PSA_WANT` counterpartarts
- Client certificate verify HOT 1
- mbedtls_pk_sign_ext() returned -16000 (-0x3e80) HOT 1
- Do not perform adjustments on legacy crypto from PSA, when MBEDTLS_PSA_CRYPTO_CLIENT && !MBEDTLS_PSA_CRYPTO_C HOT 2
- Can't disable certificate verification with TLSv1.3 HOT 2
- MBEDTLS_ERR_SSL_RECEIVED_NEW_SESSION_TICKET breaks backwards-compatibility? HOT 1
- Clean up psk_list in ssl-opt.sh
- Support the `crypto_config.h` usage in depends.py
- Update the `cipher_id` domain to use PSA macros in `depends.py`
- Update the `cipher_chaining` domain to use PSA macros in `depends.py`
- Update the `curves` domain to use PSA macros in `depends.py`
- Update the `hashes` domain to use PSA macros in `depends.py`
- Update the `pkalgs` domain to use PSA macros in `depends.py`
- Guidance to remove check_config.h inclusion from mbedtls_config.h
- CMake: Dependency scope HOT 3
- Remove hkdf.c HOT 2
- Protect against spurious definitions of derived symbols
- 2.28 only: build broken when `check_config.h` is not included
- Missing include stdlib.h and stdio.h in some platform configurations
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mbedtls.