You are not logged in.

#1 2023-04-15 14:18:58

Baird
Member
Registered: 2023-03-10
Posts: 11

variable as length of array

C++ must has constexpr as length of array, right?

What's the reason that GCC (with c++ command) compiled my .cpp file includes array with variable length?

I saw some topic about C99, is it related?

Last edited by Baird (2023-04-15 14:21:40)

Offline

#2 2023-04-17 01:40:35

mpan
Member
Registered: 2012-08-01
Posts: 1,205
Website

Re: variable as length of array

By default both g++ and gcc enable GNU extensions, including variable length arrays. To enforce standard behavior, -pedantic-errors must be passed among the options. Best used with the specific -std= option to avoid confusion.


Sometimes I seem a bit harsh — don’t get offended too easily!

Offline

Board footer

Powered by FluxBB