Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Real Programmers think better when playing Adventure or Rogue.


devel / comp.lang.c / Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

SubjectAuthor
* ANSI C89/ISO C90 - Reference where mixing declarations and code isPoprocks
+* Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbiddenScott Lurndal
|`* Re: ANSI C89/ISO C90 - Reference where mixing declarations and codeGuillaume
| `* Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbiddenTim Rentsch
|  `* Re: ANSI C89/ISO C90 - Reference where mixing declarations and codeluser droog
|   `- Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbiddenTim Rentsch
`- Re: ANSI C89/ISO C90 - Reference where mixing declarations and codeKaz Kylheku

1
ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

<slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21632&group=comp.lang.c#21632

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ple...@replytogroup.com (Poprocks)
Newsgroups: comp.lang.c
Subject: ANSI C89/ISO C90 - Reference where mixing declarations and code is
forbidden
Date: Mon, 9 May 2022 15:23:14 -0400
Organization: A noiseless patient Spider
Lines: 33
Message-ID: <slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com>
Injection-Info: reader02.eternal-september.org; posting-host="d6482c88fa607947bff64b33099e3087";
logging-data="24575"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19qWkSCG6RDCwYV+lDXfRQSKJwkkj4sNS4="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:K+oOAicPC312MaLPArzKDI4aYkg=
 by: Poprocks - Mon, 9 May 2022 19:23 UTC

Hi folks,

We all know that when one writes code like this:

```
int main(void)
{ int x;
x = 42;
int y = 5;

return 0;
} ```

....under strict C89/90, one will get a warning or error with, eg, GCC
(depending on the flags, of course. However, I thought the reference
to this rule in the ANSI C89 standard would be easy to find, but I was
perusing the full text of the C89 standard the other day and I couldn't
find it anywhere.

(eg: `gcc -Wall -std=c89 -pedantic-errors`)

Does anyone have a paragraph/section reference number for this rule
under the ANSI C89 or ISO C90 standard?

I'd like to make reference to it in a stream I'm working on, next time
I'm live.

Thanks in advance!

--
Poprocks

Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

<LmeeK.9848$gc62.6389@fx45.iad>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21633&group=comp.lang.c#21633

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx45.iad.POSTED!not-for-mail
X-newsreader: xrn 9.03-beta-14-64bit
Sender: scott@dragon.sl.home (Scott Lurndal)
From: sco...@slp53.sl.home (Scott Lurndal)
Reply-To: slp53@pacbell.net
Subject: Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden
Newsgroups: comp.lang.c
References: <slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com>
Lines: 63
Message-ID: <LmeeK.9848$gc62.6389@fx45.iad>
X-Complaints-To: abuse@usenetserver.com
NNTP-Posting-Date: Mon, 09 May 2022 19:57:31 UTC
Organization: UsenetServer - www.usenetserver.com
Date: Mon, 09 May 2022 19:57:31 GMT
X-Received-Bytes: 2212
 by: Scott Lurndal - Mon, 9 May 2022 19:57 UTC

Poprocks <please@replytogroup.com> writes:
>Hi folks,
>
>We all know that when one writes code like this:
>
>```
>int main(void)
>{
> int x;
> x = 42;
> int y = 5;
>
> return 0;
>}
>```
>
>...under strict C89/90, one will get a warning or error with, eg, GCC
>(depending on the flags, of course. However, I thought the reference
>to this rule in the ANSI C89 standard would be easy to find, but I was
>perusing the full text of the C89 standard the other day and I couldn't
>find it anywhere.
>
>(eg: `gcc -Wall -std=c89 -pedantic-errors`)
>
>Does anyone have a paragraph/section reference number for this rule
>under the ANSI C89 or ISO C90 standard?
>
>I'd like to make reference to it in a stream I'm working on, next time
>I'm live.

Looking at n1256 (C99 draft), the productions in 6.8.2 (Compound Statement)
cover the mixing of code and declaration by allowing either in 'block-item'.
C99 draft:

Syntax

compound-statement:
{ block-item-listopt }

block-item-list:
block-item
block-item-list block-item

block-item:
declaration
statement

C89:

3.6.2 Compound statement, or block

Syntax

compound-statement:
{ declaration-list<opt> statement-list<opt> }

declaration-list:
declaration
declaration-list declaration

statement-list:
statement
statement-list statement

Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

<t5c0fq$jku$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21634&group=comp.lang.c#21634

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!aioe.org!s486zuCnr7HM/CNE9BFibw.user.46.165.242.75.POSTED!not-for-mail
From: mess...@bottle.org (Guillaume)
Newsgroups: comp.lang.c
Subject: Re: ANSI C89/ISO C90 - Reference where mixing declarations and code
is forbidden
Date: Mon, 9 May 2022 23:18:50 +0200
Organization: Aioe.org NNTP Server
Message-ID: <t5c0fq$jku$1@gioia.aioe.org>
References: <slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com>
<LmeeK.9848$gc62.6389@fx45.iad>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="20126"; posting-host="s486zuCnr7HM/CNE9BFibw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.9.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: fr
 by: Guillaume - Mon, 9 May 2022 21:18 UTC

Le 09/05/2022 à 21:57, Scott Lurndal a écrit :
> Poprocks <please@replytogroup.com> writes:
>> Hi folks,
>>
>> We all know that when one writes code like this:
>>
>> ```
>> int main(void)
>> {
>> int x;
>> x = 42;
>> int y = 5;
>>
>> return 0;
>> }
>> ```
>>
>> ...under strict C89/90, one will get a warning or error with, eg, GCC
>> (depending on the flags, of course. However, I thought the reference
>> to this rule in the ANSI C89 standard would be easy to find, but I was
>> perusing the full text of the C89 standard the other day and I couldn't
>> find it anywhere.
>>
>> (eg: `gcc -Wall -std=c89 -pedantic-errors`)
>>
>> Does anyone have a paragraph/section reference number for this rule
>> under the ANSI C89 or ISO C90 standard?
>>
>> I'd like to make reference to it in a stream I'm working on, next time
>> I'm live.
>
> Looking at n1256 (C99 draft), the productions in 6.8.2 (Compound Statement)
> cover the mixing of code and declaration by allowing either in 'block-item'.
> C99 draft:
>
> Syntax
>
> compound-statement:
> { block-item-listopt }
>
> block-item-list:
> block-item
> block-item-list block-item
>
> block-item:
> declaration
> statement
>
> C89:
>
> 3.6.2 Compound statement, or block
>
> Syntax
>
> compound-statement:
> { declaration-list<opt> statement-list<opt> }
>
> declaration-list:
> declaration
> declaration-list declaration
>
> statement-list:
> statement
> statement-list statement

Yes. It's not *explicitely* stated in the C90 std other than from the
grammar, which defines compound statements as a declaration list
(optional) followed by a statement list (optional). Thus, as per the
grammar, declarations can't come after statements.

And function bodies are defined as compound statements, so you have your
whole case.

There's a summary of the grammar in annex B of ISO C90 and annex A of
C99 and upwards. I find it unfortunate that the grammar is not expressed
as BNF or something similar, but we have to do with what's available. As
it is given it lacks a synthetic, hierarchical view. IMHO.

Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

<20220509141839.961@kylheku.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21635&group=comp.lang.c#21635

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: 480-992-...@kylheku.com (Kaz Kylheku)
Newsgroups: comp.lang.c
Subject: Re: ANSI C89/ISO C90 - Reference where mixing declarations and code
is forbidden
Date: Mon, 9 May 2022 21:21:41 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 15
Message-ID: <20220509141839.961@kylheku.com>
References: <slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com>
Injection-Date: Mon, 9 May 2022 21:21:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="cad784bd4f3a09c4d614e3d03c7d15ac";
logging-data="27989"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18eUdVxlRPQzdF2FQOrmNz7AVULR+YeRvY="
User-Agent: slrn/1.0.3 (Linux)
Cancel-Lock: sha1:FYvHqBKH9hnYZodB0FVUnV+8jpw=
 by: Kaz Kylheku - Mon, 9 May 2022 21:21 UTC

On 2022-05-09, Poprocks <please@replytogroup.com> wrote:
> ...under strict C89/90, one will get a warning or error with, eg, GCC
> (depending on the flags, of course. However, I thought the reference
> to this rule in the ANSI C89 standard would be easy to find, but I was
> perusing the full text of the C89 standard the other day and I couldn't
> find it anywhere.

The rule is that in a compound statement, there is a list of zero or
more declarations, followed by zero or more statements.

Look for the compound statement syntax.

--
TXR Programming Language: http://nongnu.org/txr
Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal

Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

<86ee103yrn.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21652&group=comp.lang.c#21652

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden
Date: Wed, 11 May 2022 07:54:52 -0700
Organization: A noiseless patient Spider
Lines: 20
Message-ID: <86ee103yrn.fsf@linuxsc.com>
References: <slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com> <LmeeK.9848$gc62.6389@fx45.iad> <t5c0fq$jku$1@gioia.aioe.org>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="6e053f3c0f02a0908dcde38e6a89f991";
logging-data="19820"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19bcyqC8l4PP7drTW+LQDvJASMoBb4kdBw="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:jQLRqEKwV8mcqFofdRrtJvuwP7c=
sha1:A7EywDrJ16Yijkddsb/8cDl5Kw0=
 by: Tim Rentsch - Wed, 11 May 2022 14:54 UTC

Guillaume <message@bottle.org> writes:

[.. regarding C grammar rules ..]

> There's a summary of the grammar in annex B of ISO C90 and annex A
> of C99 and upwards. I find it unfortunate that the grammar is not
> expressed as BNF or something similar, [...]

The C90 and C99 grammar rules are not written in BNF, but surely
they deserve to be termed something similar. They can easily
be mapped to BNF, for example, if one wants to do that.

> As it is given it lacks a synthetic, hierarchical view. IMHO.

I don't know what you mean by those two adjectives here. Can you
give an example illustrating a hierarchical view? And also an
example illustrating a synthetic view? To keep things relatively
simple, let's say for the syntactic category 'expression' in C90,
and omitting anything having to do with type names more than just
a single identifier.

Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

<a6ca5d85-b74c-42d6-b361-57c98f0cbc0fn@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21671&group=comp.lang.c#21671

  copy link   Newsgroups: comp.lang.c
X-Received: by 2002:a05:620a:24cd:b0:6a0:414c:a648 with SMTP id m13-20020a05620a24cd00b006a0414ca648mr2175497qkn.465.1652408210410;
Thu, 12 May 2022 19:16:50 -0700 (PDT)
X-Received: by 2002:a05:620a:458b:b0:6a0:3399:c9dd with SMTP id
bp11-20020a05620a458b00b006a03399c9ddmr2173573qkb.630.1652408210143; Thu, 12
May 2022 19:16:50 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.c
Date: Thu, 12 May 2022 19:16:49 -0700 (PDT)
In-Reply-To: <86ee103yrn.fsf@linuxsc.com>
Injection-Info: google-groups.googlegroups.com; posting-host=24.207.219.108; posting-account=G1KGwgkAAAAyw4z0LxHH0fja6wAbo7Cz
NNTP-Posting-Host: 24.207.219.108
References: <slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com>
<LmeeK.9848$gc62.6389@fx45.iad> <t5c0fq$jku$1@gioia.aioe.org> <86ee103yrn.fsf@linuxsc.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <a6ca5d85-b74c-42d6-b361-57c98f0cbc0fn@googlegroups.com>
Subject: Re: ANSI C89/ISO C90 - Reference where mixing declarations and code
is forbidden
From: luser.dr...@gmail.com (luser droog)
Injection-Date: Fri, 13 May 2022 02:16:50 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2138
 by: luser droog - Fri, 13 May 2022 02:16 UTC

On Wednesday, May 11, 2022 at 9:55:07 AM UTC-5, Tim Rentsch wrote:
> Guillaume <mes...@bottle.org> writes:
>
> [.. regarding C grammar rules ..]
> > There's a summary of the grammar in annex B of ISO C90 and annex A
> > of C99 and upwards. I find it unfortunate that the grammar is not
> > expressed as BNF or something similar, [...]
>
> The C90 and C99 grammar rules are not written in BNF, but surely
> they deserve to be termed something similar. They can easily
> be mapped to BNF, for example, if one wants to do that.

Mapping to BNF is easy enough, true. I (and I suspect others) would have
an easier time with it if it were left factored so it can be used directly by
the simpler parsing algorithms. Left factoring by hand I've found to be
tedious and error prone. And if you make a tool to do it, then you're not
in "simple parsing algorithm" territory anymore, sigh.

Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden

<865ym652ll.fsf@linuxsc.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=21690&group=comp.lang.c#21690

  copy link   Newsgroups: comp.lang.c
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: tr.17...@z991.linuxsc.com (Tim Rentsch)
Newsgroups: comp.lang.c
Subject: Re: ANSI C89/ISO C90 - Reference where mixing declarations and code is forbidden
Date: Sun, 15 May 2022 06:48:06 -0700
Organization: A noiseless patient Spider
Lines: 23
Message-ID: <865ym652ll.fsf@linuxsc.com>
References: <slrnt7iqh2.7db.please@loganrpi.rathbonelaw.com> <LmeeK.9848$gc62.6389@fx45.iad> <t5c0fq$jku$1@gioia.aioe.org> <86ee103yrn.fsf@linuxsc.com> <a6ca5d85-b74c-42d6-b361-57c98f0cbc0fn@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Injection-Info: reader02.eternal-september.org; posting-host="90fae27f8c3ebf4ec54f5551ea17134b";
logging-data="1405"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/7J/k5iGOVTJcGm6T1sdlPF/f3wZ3vQu8="
User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.4 (gnu/linux)
Cancel-Lock: sha1:7+kDlAAMf1/35y5wINCHWbtNrhQ=
sha1:A4uBJ5LLXxGuyoQM3a15yRt4HSw=
 by: Tim Rentsch - Sun, 15 May 2022 13:48 UTC

luser droog <luser.droog@gmail.com> writes:

> On Wednesday, May 11, 2022 at 9:55:07 AM UTC-5, Tim Rentsch wrote:
>
>> Guillaume <mes...@bottle.org> writes:
>>
>> [.. regarding C grammar rules ..]
>>
>>> There's a summary of the grammar in annex B of ISO C90 and annex A
>>> of C99 and upwards. I find it unfortunate that the grammar is not
>>> expressed as BNF or something similar, [...]
>>
>> The C90 and C99 grammar rules are not written in BNF, but surely
>> they deserve to be termed something similar. They can easily
>> be mapped to BNF, for example, if one wants to do that.
>
> Mapping to BNF is easy enough, true. I (and I suspect others)
> would have an easier time with it if it were left factored so it
> can be used directly by the simpler parsing algorithms. [...]

But doing that would make it harder for people to read and
understand, which is after all the primary purpose of the C
standard.

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor