c++ - C++11 variable size POD struct -
i writing low-lewel data manipulation code in c++ 11 , want use old-known c feature of flexible arrays @ end of struct (see info here).
struct variablecell { /** * @brief size in bytes of following data. */ std::uint32_t cellsize; /** * @brief data stored in overlay. */ std::uint8_t celldata[]; };
once use gcc paramaters
-wall -pedantic -std=c++11
i waring
xxx.h:xx: warning: iso c++ forbids zero-size array 'variablecell' [-wpedantic]
this used correct feature. please, not tell me approach wrong - , has been correct way low-level data manipulation.
why standard changed , how disable 1 particular warning?
thanks
edit: apologies, mistaken c feature turned 1 of exceptions not c++ include. consider using different approach. curiosity, compilers allows non-standard extension , how make them accept without warning?
thanks
as reference incompatibilities between iso c , iso c++ states in flexible array members section:
c++ not support flexible array members.
(this feature might provided extension c++ compilers, valid pod structure types.)
gcc support extension clang. apparently works in visual studio - see live if don't use /za
can find documentation on besides post stephan t. lavavej.
i don't think there portable way silence warning, partially disable pedantic warnings in gcc within source should work gcc
.
Comments
Post a Comment