program 1
#include <iostream> std::size_t three() { return 3; } int i[three()]; int main() { return 0; }
program 2
std::size_t three() { return 3; } int main() { int i[three()]; return 0; }
The problem here in program 1, as expected, gives a compilation error
": array bound is not an integer constant before the ']' token
But I have no idea why program 2 compiled successfully?
C99 int i[three()]; , . , , C99. main() , , , , C99.
int i[three()];
main()
, GCC Clang, C89 ++ . ++ . GCC Clang , -pedantic.
-pedantic
Source: https://habr.com/ru/post/1548721/More articles:How to cancel an asynchronous http request in Objective-C? - asynchronousHortonworks HA Namenodes gives error "READ operation category not supported in pending state" - hadoopHow to save an interactive plot created by ggvis? - rPython: Unicode encoding different from Mac and Ubuntu - pythonHow to disable beforeSave logging after interception in parsing - javascriptMissing Unicode codecs on kivy / Python on Android? - pythonПочему я могу объявить массив с предопределенным размером на gcc, но не на visual studio С++? - cWhy should we write SET FMTONLY OFF in stored procedures when using the Entity Framework - sql-serverHow to interrupt a synchronized method that is locked - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1548726/qml-using-scrollview-leads-to-incorrect-displaying-of-elements&usg=ALkJrhjbUv2BDtUi4mzwiwMEX5OrIO-wfAAll Articles