Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #106069

Re: Two C code questions

Path csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Keith Thompson <kst-u@mib.org>
Newsgroups comp.lang.c
Subject Re: Two C code questions
Date Tue, 14 Mar 2017 11:49:58 -0700
Organization None to speak of
Lines 27
Message-ID <lnzignitgp.fsf@kst-u.example.com> (permalink)
References <oa7oru$rkf$1@dont-email.me> <468c93a0-7b2d-4eab-8266-39737867b9ac@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Injection-Info mx02.eternal-september.org; posting-host="68145e82dff5cec9d4077a7833a68c0b"; logging-data="29072"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/AWKCyrjL9MYCl3MqqApvc"
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux)
Cancel-Lock sha1:5K3EOEBILiXpP+6JIa3h1eZQldU= sha1:BqvZPTuzTOtf3RGLws7o+lP+6u4=
Xref csiph.com comp.lang.c:106069

Show key headers only | View raw


John Bode <jfbode1029@gmail.com> writes:
> On Monday, March 13, 2017 at 10:45:53 PM UTC-5, Mehdi Amini Valashani son of Bahram wrote:
[...]
>> int main(void)
>> {
>>      uint64_t ui[N] = {0};
>> 
>
> For C89 and earlier, array dimensions must be *constant expressions*; i.e.,
> something that can be evaluated at compile time (integer literals, sizeof
> expressions, macros that expand to either literals or sizeof expressions,
> arithmetic expressions that involve any of the previous, etc.).  
>
> A variable declared as "static const" is *not* a constant expression - its
> value is not evaluated at compile time.  
>
> C99 introduced variable-length arrays, whose size doesn't have to be 
> established until run time; if you compiled that code under a C99 compiler,
> it should work.  

No, C99 doesn't allow VLAs to be initialized (nor does C11).

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"

Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Two C code questions MehdiAmini <atorrses@gmail.com> - 2017-03-14 07:15 +0330
  Re: Two C code questions Joe Pfeiffer <pfeiffer@cs.nmsu.edu> - 2017-03-13 22:13 -0600
  Re: Two C code questions Ian Collins <ian-news@hotmail.com> - 2017-03-14 17:16 +1300
  Re: Two C code questions Ike Naar <ike@iceland.freeshell.org> - 2017-03-14 07:20 +0000
    Re: Two C code questions MehdiAmini <atorrses@gmail.com> - 2017-03-14 12:01 +0330
      Re: Two C code questions Ike Naar <ike@iceland.freeshell.org> - 2017-03-14 19:23 +0000
        Re: Two C code questions Keith Thompson <kst-u@mib.org> - 2017-03-14 12:40 -0700
  Re: Two C code questions scott@slp53.sl.home (Scott Lurndal) - 2017-03-14 12:44 +0000
  Re: Two C code questions Keith Thompson <kst-u@mib.org> - 2017-03-14 08:53 -0700
    Re: Two C code questions MehdiAmini <atorrses@gmail.com> - 2017-03-15 14:05 +0330
  Re: Two C code questions John Bode <jfbode1029@gmail.com> - 2017-03-14 10:38 -0700
    Re: Two C code questions Keith Thompson <kst-u@mib.org> - 2017-03-14 11:49 -0700
      Re: Two C code questions John Bode <jfbode1029@gmail.com> - 2017-03-14 14:14 -0700

csiph-web