Re: Two questions on arrays with size defined by variables

Liste des GroupesRevenir à cl c 
Sujet : Re: Two questions on arrays with size defined by variables
De : antispam (at) *nospam* fricas.org (Waldek Hebisch)
Groupes : comp.lang.c
Date : 09. Feb 2025, 15:29:00
Autres entêtes
Organisation : To protect and to server
Message-ID : <voae3a$2rke4$1@paganini.bofh.team>
References : 1 2 3
User-Agent : tin/2.6.2-20221225 ("Pittyvaich") (Linux/6.1.0-9-amd64 (x86_64))
Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote:
 
And in "C" (C99) I tried it *without* the _inner block_
 
main ()
{
  int n = 5;
  char * arr[n];
  ...
}
 
and it seemed to work that way. (In those other languages that wasn't
possible.)

Hmm, IIRC both (Extended) Pascal and PL/I allow VLA within function
in places where they allow variable declarations, so really no
special _inner block_ requirement (just must be local to a function).

 
Q1: Is this a correct (portable) form?
 
VLA objects have to be declared locally. However, keep in mind that
support for local declarations of VLA _objects_ is now optional (i.e.
not portable). Support for variably-modified _types_ themselves (VLA
types) is mandatory. But you are not guaranteed to be able to declare an
actual VLA variable.
 
I fear I don't understand what you're saying here. - By "now" do you
mean newer versions of the C standards? That you can rely only, say,
rely on it with C99 but maybe not before and not in later C standards
conforming compilers?
 
For my purpose it would be okay to know whether with the C99 version
(that I used) it's okay, or whether that's some GNU specific extension
or some such.

This used to be GCC extention, AFAIK present in all versions of
GCC.  It was standarized in C99 and is now available in reasonable
C compilers like curent tcc (Tiny C).  But AFAIK it is not present
in Microsoft C.  And probably not present in historic C compilers
like compilers for old proprietary Unices or historic tcc (Tendra
C compiler).  As already mentioned compiler can claim C11 or C23
compliance but do not implement VLA (VMT are optional in C11
but mandatoryu in C23, VLA are optional both in C11 and C23).

--
                              Waldek Hebisch

Date Sujet#  Auteur
9 Feb 25 * Two questions on arrays with size defined by variables45Janis Papanagnou
9 Feb 25 `* Re: Two questions on arrays with size defined by variables44Andrey Tarasevich
9 Feb 25  +* Re: Two questions on arrays with size defined by variables41Janis Papanagnou
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables10Keith Thompson
9 Feb 25  ii`* Re: Two questions on arrays with size defined by variables9Janis Papanagnou
10 Feb 25  ii `* Re: Two questions on arrays with size defined by variables8Keith Thompson
10 Feb 25  ii  `* Re: Two questions on arrays with size defined by variables7Janis Papanagnou
10 Feb 25  ii   +- Re: Two questions on arrays with size defined by variables1James Kuyper
10 Feb 25  ii   `* Re: Two questions on arrays with size defined by variables5Andrey Tarasevich
10 Feb 25  ii    `* Re: Two questions on arrays with size defined by variables4Janis Papanagnou
10 Feb 25  ii     `* Re: Two questions on arrays with size defined by variables3Keith Thompson
10 Feb 25  ii      `* Re: Two questions on arrays with size defined by variables2Janis Papanagnou
10 Feb 25  ii       `- Re: Two questions on arrays with size defined by variables1Keith Thompson
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables6Michael S
9 Feb 25  ii`* Re: Two questions on arrays with size defined by variables5Janis Papanagnou
9 Feb 25  ii `* Re: Two questions on arrays with size defined by variables4Michael S
9 Feb 25  ii  +- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
10 Feb 25  ii  `* Re: Two questions on arrays with size defined by variables2Keith Thompson
10 Feb 25  ii   `- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables20Waldek Hebisch
9 Feb 25  ii`* Re: Two questions on arrays with size defined by variables19Janis Papanagnou
9 Feb 25  ii +* Re: Two questions on arrays with size defined by variables13Andrey Tarasevich
9 Feb 25  ii i`* Re: Two questions on arrays with size defined by variables12Janis Papanagnou
9 Feb 25  ii i +* Re: Two questions on arrays with size defined by variables7Janis Papanagnou
9 Feb 25  ii i i`* Re: Two questions on arrays with size defined by variables6James Kuyper
10 Feb 25  ii i i +- Re: Two questions on arrays with size defined by variables1Waldek Hebisch
10 Feb 25  ii i i `* Re: Two questions on arrays with size defined by variables4Janis Papanagnou
10 Feb 25  ii i i  `* Re: Two questions on arrays with size defined by variables3David Brown
10 Feb 25  ii i i   `* Re: Two questions on arrays with size defined by variables2Janis Papanagnou
10 Feb 25  ii i i    `- Re: Two questions on arrays with size defined by variables1David Brown
9 Feb 25  ii i `* Re: Two questions on arrays with size defined by variables4Michael S
10 Feb 25  ii i  `* Re: Two questions on arrays with size defined by variables3Opus
10 Feb 25  ii i   `* Re: Two questions on arrays with size defined by variables2Michael S
10 Feb 25  ii i    `- Re: Two questions on arrays with size defined by variables1Opus
10 Feb 25  ii `* Re: Two questions on arrays with size defined by variables5Keith Thompson
10 Feb 25  ii  `* Re: Two questions on arrays with size defined by variables4Janis Papanagnou
10 Feb 25  ii   `* Re: Two questions on arrays with size defined by variables3Janis Papanagnou
10 Feb 25  ii    `* Re: Two questions on arrays with size defined by variables2Keith Thompson
10 Feb 25  ii     `- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
9 Feb 25  i+* Re: Two questions on arrays with size defined by variables3Andrey Tarasevich
9 Feb 25  ii+- Re: Two questions on arrays with size defined by variables1Janis Papanagnou
9 Feb 25  ii`- Re: Two questions on arrays with size defined by variables1James Kuyper
9 Feb 25  i`- Re: Two questions on arrays with size defined by variables1James Kuyper
9 Feb 25  +- Re: Two questions on arrays with size defined by variables1James Kuyper
15 Feb17:19  `- Re: Two questions on arrays with size defined by variables1Tim Rentsch

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal