Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #129666 > unrolled thread
| Started by | Dan Purgert <dan@djph.net> |
|---|---|
| First post | 2018-04-24 13:39 +0000 |
| Last post | 2018-04-27 00:23 -0700 |
| Articles | 20 on this page of 131 — 31 participants |
Back to article view | Back to comp.lang.c
Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-24 13:39 +0000
Re: Need some help getting to my feet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-24 16:38 +0100
Re: Need some help getting to my feet Real Troll <real.troll@trolls.com> - 2018-04-24 13:40 -0400
Re: Need some help getting to my feet Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-24 08:38 -0700
[Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-24 18:06 +0000
Re: [Solved] Need some help getting to my feet Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-25 07:33 -0700
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-25 07:49 -0700
Re: [Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-25 21:28 +0000
Re: [Solved] Need some help getting to my feet antispam@math.uni.wroc.pl - 2018-04-28 14:26 +0000
Re: [Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-28 20:25 +0000
Re: [Solved] Need some help getting to my feet antispam@math.uni.wroc.pl - 2018-04-29 15:12 +0000
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-29 16:49 +0100
Re: [Solved] Need some help getting to my feet antispam@math.uni.wroc.pl - 2018-04-30 15:30 +0000
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-30 17:06 +0100
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-30 09:12 -0700
Re: [Solved] Need some help getting to my feet C W Rose <cwr@seckford.org> - 2018-05-02 15:19 +0100
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-05-02 07:54 -0700
Re: [Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-05-03 12:45 +0000
Re: [Solved] Need some help getting to my feet antispam@math.uni.wroc.pl - 2018-05-05 14:22 +0000
Re: [Solved] Need some help getting to my feet Steve Carroll <frelwizzen@gmail.com> - 2018-05-05 08:42 -0700
Re: [Solved] Need some help getting to my feet C W Rose <cwr@seckford.org> - 2018-05-07 16:34 +0100
Re: [Solved] Need some help getting to my feet Steve Carroll <frelwizzen@gmail.com> - 2018-05-07 09:37 -0700
Re: [Solved] Need some help getting to my feet Wouter Verhelst <w@uter.be> - 2018-05-04 10:19 +0200
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-05-04 11:31 +0100
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-29 08:53 -0700
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-29 18:14 -0700
Re: [Solved] Need some help getting to my feet Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-04-25 08:54 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-25 09:24 -0700
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-25 18:10 +0100
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-25 10:48 -0700
Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) gazelle@shell.xmission.com (Kenny McCormack) - 2018-04-25 19:23 +0000
Re: Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) Bruce S <bruces42@hotmail.com> - 2018-04-25 16:55 -0600
Re: Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-04-25 16:03 -0700
Re: Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) Bruce S <bruces42@hotmail.com> - 2018-04-25 18:02 -0600
Re: Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) "Chris M. Thomasson" <invalid_chris_thomasson@invalid.invalid> - 2018-04-25 17:14 -0700
Re: Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) Bruce S <bruces42@hotmail.com> - 2018-04-26 13:31 -0600
Re: Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) gazelle@shell.xmission.com (Kenny McCormack) - 2018-04-26 03:27 +0000
Re: Casting the return value of malloc() (Was: [Solved] Need some help getting to my feet) Dan Purgert <dan@djph.net> - 2018-04-26 11:06 +0000
Re: [Solved] Need some help getting to my feet 1alvinalbrecht1@gmail.com - 2018-04-25 18:41 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-26 07:26 -0700
Re: [Solved] Need some help getting to my feet Spiros Bousbouras <spibou@gmail.com> - 2018-04-25 16:26 +0000
Re: [Solved] Need some help getting to my feet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-25 21:50 +0100
Re: [Solved] Need some help getting to my feet Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-04-26 01:47 -0700
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-26 02:18 -0700
Re: [Solved] Need some help getting to my feet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-26 11:18 +0100
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-26 11:33 +0100
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-26 05:26 -0700
Re: [Solved] Need some help getting to my feet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-27 00:09 +0100
Re: [Solved] Need some help getting to my feet Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-04-26 09:14 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-26 10:26 -0700
Re: [Solved] Need some help getting to my feet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-27 00:02 +0100
Re: [Solved] Need some help getting to my feet Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-04-27 02:35 -0700
Re: [Solved] Need some help getting to my feet Ben Bacarisse <ben.usenet@bsb.me.uk> - 2018-04-27 11:34 +0100
Re: [Solved] Need some help getting to my feet mark.bluemel@gmail.com - 2018-04-27 04:14 -0700
STDIO.H vs stdio.h (Was: [Solved] Need some help getting to my feet) gazelle@shell.xmission.com (Kenny McCormack) - 2018-04-27 13:08 +0000
Re: STDIO.H vs stdio.h (Was: [Solved] Need some help getting to my feet) Manfred <noname@invalid.add> - 2018-04-27 18:52 +0200
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-27 07:08 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-27 10:36 -0700
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-27 19:04 +0100
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-27 11:26 -0700
Re: [Solved] Need some help getting to my feet scott@slp53.sl.home (Scott Lurndal) - 2018-04-27 18:45 +0000
Re: [Solved] Need some help getting to my feet Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-04-30 03:43 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-30 09:10 -0700
Re: [Solved] Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-30 23:32 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-26 07:33 -0700
Re: [Solved] Need some help getting to my feet jameskuyper@verizon.net - 2018-04-26 08:38 -0700
Re: [Solved] Need some help getting to my feet already5chosen@yahoo.com - 2018-04-27 03:30 -0700
Re: [Solved] Need some help getting to my feet Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-27 08:41 -0700
Re: [Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-27 17:04 +0000
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-27 11:06 -0700
Re: [Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-27 20:15 +0000
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-27 13:47 -0700
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-27 22:06 +0100
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-27 14:51 -0700
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-28 00:25 +0100
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-27 17:23 -0700
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-28 01:39 +0100
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-27 19:22 -0700
Re: [Solved] Need some help getting to my feet Wouter Verhelst <w@uter.be> - 2018-05-04 10:36 +0200
Re: [Solved] Need some help getting to my feet bartc <bc@freeuk.com> - 2018-05-04 11:21 +0100
Re: [Solved] Need some help getting to my feet Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2018-05-04 04:03 -0700
Re: [Solved] Need some help getting to my feet David Brown <david.brown@hesbynett.no> - 2018-05-04 14:03 +0200
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-05-04 09:19 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-05-04 11:00 -0700
Re: [Solved] Need some help getting to my feet David Brown <david.brown@hesbynett.no> - 2018-05-05 18:39 +0200
Re: [Solved] Need some help getting to my feet Steve Carroll <frelwizzen@gmail.com> - 2018-05-07 16:23 -0700
Re: [Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-28 12:11 +0000
Re: [Solved] Need some help getting to my feet luser droog <luser.droog@gmail.com> - 2018-04-27 14:12 -0700
Re: [Solved] Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-28 12:21 +0000
Re: [Solved] Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-05-04 13:31 +0000
Re: [Solved] Need some help getting to my feet luser droog <luser.droog@gmail.com> - 2018-05-04 17:19 -0700
Re: [Solved] Need some help getting to my feet Tim Rentsch <txr@alumni.caltech.edu> - 2018-05-18 21:55 -0700
Re: [Solved] Need some help getting to my feet already5chosen@yahoo.com - 2018-05-21 03:26 -0700
Re: [Solved] Need some help getting to my feet Tim Rentsch <txr@alumni.caltech.edu> - 2018-06-14 03:00 -0700
Mixing declarations and statements in C code (Was: [Solved] Need some help getting to my feet) gazelle@shell.xmission.com (Kenny McCormack) - 2018-12-26 06:43 +0000
Re: [Solved] Need some help getting to my feet Anton Shepelev <anton.txt@g{oogle}mail.com> - 2018-12-26 19:02 +0300
Re: [Solved] Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-12-31 18:01 +0000
Re: [Solved] Need some help getting to my feet Richard Damon <Richard@Damon-Family.org> - 2018-12-31 17:16 -0500
Re: [Solved] Need some help getting to my feet Bart <bc@freeuk.com> - 2018-12-31 22:44 +0000
Re: [Solved] Need some help getting to my feet Ike Naar <ike@iceland.freeshell.org> - 2019-01-01 19:14 +0000
Re: [Solved] Need some help getting to my feet rbowman <bowman@montana.com> - 2019-01-01 13:14 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2019-01-01 12:49 -0800
Re: [Solved] Need some help getting to my feet rbowman <bowman@montana.com> - 2019-01-01 15:55 -0700
Re: [Solved] Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2019-01-01 16:05 -0800
Re: [Solved] Need some help getting to my feet rbowman <bowman@montana.com> - 2019-01-01 22:17 -0700
Re: [Solved] Need some help getting to my feet Bart <bc@freeuk.com> - 2019-01-01 20:25 +0000
Re: [Solved] Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-05-04 11:48 +0000
Re: Need some help getting to my feet Ed Kellett <e@kellett.im> - 2018-04-24 16:40 +0100
Re: Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-24 11:01 -0700
Re: Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-04-24 15:50 +0000
Re: Need some help getting to my feet Spiros Bousbouras <spibou@gmail.com> - 2018-04-24 17:21 +0000
Re: Need some help getting to my feet Real Troll <real.troll@trolls.com> - 2018-04-24 13:20 -0400
Re: Need some help getting to my feet Real Troll <real.troll@trolls.com> - 2018-04-24 13:30 -0400
Re: Need some help getting to my feet Spiros Bousbouras <spibou@gmail.com> - 2018-04-24 17:42 +0000
Re: Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-24 18:26 +0000
Re: Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-04-25 19:19 +0000
Re: Need some help getting to my feet Dan Purgert <dan@djph.net> - 2018-04-25 21:30 +0000
Re: Need some help getting to my feet bartc <bc@freeuk.com> - 2018-04-25 22:55 +0100
Re: Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-04-27 08:49 +0000
Re: Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-04-25 15:37 +0000
Re: Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-25 09:27 -0700
Re: Need some help getting to my feet Wouter Verhelst <w@uter.be> - 2018-04-26 13:22 +0200
Re: Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-26 09:21 -0700
Re: Need some help getting to my feet Jorgen Grahn <grahn+nntp@snipabacken.se> - 2018-04-27 08:16 +0000
Re: Need some help getting to my feet Tim Rentsch <txr@alumni.caltech.edu> - 2018-04-27 09:36 -0700
Re: Need some help getting to my feet Wouter Verhelst <w@uter.be> - 2018-05-04 10:41 +0200
Re: Need some help getting to my feet Spiros Bousbouras <spibou@gmail.com> - 2018-04-28 14:27 +0000
Re: Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-24 11:09 -0700
Re: Need some help getting to my feet C W Rose <cwr@seckford.org> - 2018-04-25 18:59 +0100
Re: Need some help getting to my feet Keith Thompson <kst-u@mib.org> - 2018-04-26 10:42 -0700
Re: Need some help getting to my feet Steven Petruzzellis <frelwizzen@gmail.com> - 2018-04-27 00:23 -0700
Page 5 of 7 — ← Prev page 1 2 3 4 [5] 6 7 Next page →
| From | Malcolm McLean <malcolm.arthur.mclean@gmail.com> |
|---|---|
| Date | 2018-05-04 04:03 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <8b96b4a8-b2d4-4549-8587-edaf8fbc98e1@googlegroups.com> |
| In reply to | #130134 |
On Friday, May 4, 2018 at 11:21:58 AM UTC+1, Bart wrote:
> On 04/05/2018 09:36, Wouter Verhelst wrote:
> > On 28-04-18 01:25, bartc wrote:
> >>>> At most one of these will have the correct arguments, so at least one
> >>>> call must be wrong, but the compiler will say nothing unless you
> >>>> explicitly tell it to report an error.
> >>>
> >>> So don't do that.
> >>
> >> So if someone wants to avoid inadvertently writing dangerous
> >> constructions in a program, all they have to do Not To Write Them.
> >
> > By "that", I assume Keith meant "don't write foo() when you mean foo(void)".
> >
> > Once you do that, my gcc starts complaining about your f("one", "two",
> > "three"); as a call with too many arguments.
> >
>
> Yes, but ... suppose someone writes foo() by mistake. How is that going
> to be detected? Example:
>
> c:\c>type c.c
> void foo();
>
> int main(void){
> foo("one","two","three");
> }
>
>
After forty years' experience with C, we know that variadic functions
are useful for implementing the printf() family, but for few other
purposes.
That wasn't clear when Dennis Ritchie wrote the first C compiler,
and the need to support printf() dominated the C calling convention.
It also meant that there had to be some fast and looseness with
parameter passing.
If we were implementing C from scratch, likely sprintf() would be a
built-in or special cased function.
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2018-05-04 14:03 +0200 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <pchi5m$eh$1@dont-email.me> |
| In reply to | #130138 |
On 04/05/18 13:03, Malcolm McLean wrote:
> On Friday, May 4, 2018 at 11:21:58 AM UTC+1, Bart wrote:
>> On 04/05/2018 09:36, Wouter Verhelst wrote:
>>> On 28-04-18 01:25, bartc wrote:
>>>>>> At most one of these will have the correct arguments, so at least one
>>>>>> call must be wrong, but the compiler will say nothing unless you
>>>>>> explicitly tell it to report an error.
>>>>>
>>>>> So don't do that.
>>>>
>>>> So if someone wants to avoid inadvertently writing dangerous
>>>> constructions in a program, all they have to do Not To Write Them.
>>>
>>> By "that", I assume Keith meant "don't write foo() when you mean foo(void)".
>>>
>>> Once you do that, my gcc starts complaining about your f("one", "two",
>>> "three"); as a call with too many arguments.
>>>
>>
>> Yes, but ... suppose someone writes foo() by mistake. How is that going
>> to be detected? Example:
>>
>> c:\c>type c.c
>> void foo();
>>
>> int main(void){
>> foo("one","two","three");
>> }
gcc -Wstrict-prototypes.
Don't ask me why this is not in -Wall, or at least -Wextra. It should
be enabled by default, in my opinion. (Yes, I know it is still legal C
and therefore gcc supports it by default. But a compiler is allowed to
give warnings even on legal code.)
>>
>>
> After forty years' experience with C, we know that variadic functions
> are useful for implementing the printf() family, but for few other
> purposes.
Agreed.
But "void foo();" is not a declaration of a variadic function - it is a
non-prototype function declaration, which has been obsolete since
C89/C90. It should have been changed to a syntax error in C99 or C11 -
it is absurd that it is still with us. And it is absurd that a compiler
like gcc does not complain about it by default.
The correct declaration for printf, the archetypical variadic function, is:
int printf(const char * restrict format, ...);
> That wasn't clear when Dennis Ritchie wrote the first C compiler,
> and the need to support printf() dominated the C calling convention.
> It also meant that there had to be some fast and looseness with
> parameter passing.
> If we were implementing C from scratch, likely sprintf() would be a
> built-in or special cased function.
>
Or printf functionality would be handled in a completely different way
(like C++'s ostream operators - which also have their good points and
their bad points).
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2018-05-04 09:19 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <lnfu37cs0t.fsf@kst-u.example.com> |
| In reply to | #130134 |
bartc <bc@freeuk.com> writes:
> On 04/05/2018 09:36, Wouter Verhelst wrote:
>> On 28-04-18 01:25, bartc wrote:
>>>>> At most one of these will have the correct arguments, so at least one
>>>>> call must be wrong, but the compiler will say nothing unless you
>>>>> explicitly tell it to report an error.
>>>>
>>>> So don't do that.
>>>
>>> So if someone wants to avoid inadvertently writing dangerous
>>> constructions in a program, all they have to do Not To Write Them.
>>
>> By "that", I assume Keith meant "don't write foo() when you mean foo(void)".
Yes.
>> Once you do that, my gcc starts complaining about your f("one", "two",
>> "three"); as a call with too many arguments.
>
> Yes, but ... suppose someone writes foo() by mistake. How is that
> going to be detected?
It likely won't be detected by the compiler. gcc doesn't complain
by default, or with a reasonable set of command-line options.
There might be an option that will cause it to warn about it.
(clang, with reasonable options, warns about an incorrect call but
not about the declaration.)
Old-style non-prototype function declarations are still part of the
language, though they're marked as obsolescent. There is rarely,
if ever, a good reason to use them. At least some compilers won't
help you detect uses of them.
Yes, this is unfortunate. I wish they had been removed from the
language in C99 or C11, and I wish gcc could be coaxed to warn
about them. (There have been discussions about reasons to keep
them in the language; I would prefer not to go over that again here.)
Nevertheless, avoiding old-style function declarations is not that
difficult, and they can be detected by reviewing your code.
This is me, again, agreeing with one of your complaints about C.
As usual, I expect you will refuse to acknowledge this and probably
blame me personally for something I am describing, not defending.
--
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"
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2018-05-04 11:00 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <ln36z7cndq.fsf@kst-u.example.com> |
| In reply to | #130187 |
Keith Thompson <kst-u@mib.org> writes:
> bartc <bc@freeuk.com> writes:
[...]
>> Yes, but ... suppose someone writes foo() by mistake. How is that
>> going to be detected?
>
> It likely won't be detected by the compiler. gcc doesn't complain
> by default, or with a reasonable set of command-line options.
> There might be an option that will cause it to warn about it.
> (clang, with reasonable options, warns about an incorrect call but
> not about the declaration.)
As David Brown points out, the option is "-Wstrict-prototypes" (which is
not included in "-Wextra" or -Wall").
[...]
--
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"
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2018-05-05 18:39 +0200 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <pckmnb$qav$1@dont-email.me> |
| In reply to | #130202 |
On 04/05/18 20:00, Keith Thompson wrote: > Keith Thompson <kst-u@mib.org> writes: >> bartc <bc@freeuk.com> writes: > [...] >>> Yes, but ... suppose someone writes foo() by mistake. How is that >>> going to be detected? >> >> It likely won't be detected by the compiler. gcc doesn't complain >> by default, or with a reasonable set of command-line options. >> There might be an option that will cause it to warn about it. >> (clang, with reasonable options, warns about an incorrect call but >> not about the declaration.) > > As David Brown points out, the option is "-Wstrict-prototypes" (which is > not included in "-Wextra" or -Wall"). > Yes. And while it is something I always have in my list of options for my builds, I fully agree with you that it is not part of a "reasonable set of command-line options". (My non-scientific definition of "reasonable set of command-line options" would by options you might remember off-hand and typically have when writing a gcc command at a bash prompt - as distinct from a more complete set that you might have in a Makefile after a look at the reference manual.)
[toc] | [prev] | [next] | [standalone]
| From | Steve Carroll <frelwizzen@gmail.com> |
|---|---|
| Date | 2018-05-07 16:23 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <f0b050a8-6e33-4409-8c6e-856bf840d758@googlegroups.com> |
| In reply to | #130242 |
On Saturday, May 5, 2018 at 9:39:15 AM UTC-7, David Brown wrote: > On 04/05/18 20:00, Keith Thompson wrote: > > Keith Thompson <kst-u@mib.org> writes: > >> bartc <bc@freeuk.com> writes: > > [...] > >>> Yes, but ... suppose someone writes foo() by mistake. How is that > >>> going to be detected? > >> > >> It likely won't be detected by the compiler. gcc doesn't complain > >> by default, or with a reasonable set of command-line options. > >> There might be an option that will cause it to warn about it. > >> (clang, with reasonable options, warns about an incorrect call but > >> not about the declaration.) > > > > As David Brown points out, the option is "-Wstrict-prototypes" (which is > > not included in "-Wextra" or -Wall"). > > > > Yes. And while it is something I always have in my list of options for > my builds, I fully agree with you that it is not part of a "reasonable > set of command-line options". (My non-scientific definition of > "reasonable set of command-line options" would by options you might > remember off-hand and typically have when writing a gcc command at a > bash prompt - as distinct from a more complete set that you might have > in a Makefile after a look at the reference manual.) Steve Carroll is a false advocate's biggest fear. This is clearly an interest of Chris Ahlstrom's. Steve Carroll's computer has more cores than Chris Ahlstrom's. Steve Carroll wins. Chris Ahlstrom loses. Which gives Steve Carroll better productivity, efficiency, and error-reduction. Any horribly desperate insomniac could easily do the same. Lots of individuals persist in talking to Chris Ahlstrom. I can not criticize Steve Carroll for for his rants but, in the end, I do not get why he writes here other than to mess with Chris Ahlstrom. Steve Carroll is better at discussions as seen in a formal forum and support forums bother him too much. Steve Carroll created at least 20 KVMS in the last year or so. Let us all have a moment of silence as we honor his accomplishments! Steve Carroll owns Chris Ahlstrom in every way possible. -- Eight things to never feed your dog! http://www.5z8.info/backyard-fireworks-disasters_t7w7pu_bombbuilding Jonas Eklundh Communication
[toc] | [prev] | [next] | [standalone]
| From | Dan Purgert <dan@djph.net> |
|---|---|
| Date | 2018-04-28 12:11 +0000 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <slrnpe8p7s.jmn.dan@xps-linux.djph.net> |
| In reply to | #129873 |
Keith Thompson wrote:
> Dan Purgert <dan@djph.net> writes:
>> Keith Thompson wrote:
> [...]
>>> I think some examples in K&R2 use "implicit int", and as I recall that's
>>> addressed in the errata. Always declare and define functions with an
>>> explicit return type.
>>
>> So far I haven't run across that, but I'm only in chapter 1 still.
>> Working through slow / rereading the sections a few times so that it
>> sticks.
>
> You might have run across it without realizing it. The very first
> example in K&R2 section 1.1 (I'm using the Kindle edition) is:
>
> #include <stdio.h>
>
> main()
> {
> printf("hello, world\n");
> }
>
> The "main()" line is an old-style non-prototype (`main()` should be
> `main(void)`) *and* it relies on the obsolete "implicit int" rule
> (it should be preceded with `int`):
>
> int main(void)
Now that you pointed it out, I indeed mentally added the returntype and
parameters without even thinking as I was typing out that example. Seems
my visual code-checker still sorta works. :)
Took out the int in my code, and the compiler threw a warning, so there
is that.
--
|_|O|_| Registered Linux user #585947
|_|_|O| Github: https://github.com/dpurgert
|O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281
[toc] | [prev] | [next] | [standalone]
| From | luser droog <luser.droog@gmail.com> |
|---|---|
| Date | 2018-04-27 14:12 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <f4bed170-4539-4c8e-ad47-5a8ec9a4f71d@googlegroups.com> |
| In reply to | #129872 |
On Friday, April 27, 2018 at 3:16:07 PM UTC-5, Dan Purgert wrote: > Keith Thompson wrote: > > In my opinion, you can get a good start learning the language from K&R2 > > (if you have some existing programming experience). You can pick up the > > changes made by C99 and C11 later on. > > That is what it sounded like from the others, so it's what I'm going > with. We'll see how on track I can stay. I've been following this discussion and I think I finally have something to contribute. After K&R2, there's a very good book /Deep C Secrets/ by Peter Van der Linden which I think is a great second book on C. If you're working in a Linux/Unix environment, then 2 excellent 3rd and 4th books are K&Pike /The Unix Programming Enviroment/ and Axel Schreiner /Curses, Lex, and Yacc/. > > I think some examples in K&R2 use "implicit int", and as I recall that's > > addressed in the errata. Always declare and define functions with an > > explicit return type. > > So far I haven't run across that, but I'm only in chapter 1 still. > Working through slow / rereading the sections a few times so that it > sticks. > > Honestly, a lot of the syntax is already starting to feel familiar > again. But I've only read through §1.9 so far ... really have to go > back and do the exercises -- kinda hard to do them on the bus. For that I suggest pencil and paper. I usually prefer pens, but pencil makes fewer ugly blotches when the bus hits a bump or taps the brake.
[toc] | [prev] | [next] | [standalone]
| From | Dan Purgert <dan@djph.net> |
|---|---|
| Date | 2018-04-28 12:21 +0000 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <slrnpe8pqs.jmn.dan@xps-linux.djph.net> |
| In reply to | #129875 |
luser droog wrote: > On Friday, April 27, 2018 at 3:16:07 PM UTC-5, Dan Purgert wrote: >> Keith Thompson wrote: > >> > In my opinion, you can get a good start learning the language from K&R2 >> > (if you have some existing programming experience). You can pick up the >> > changes made by C99 and C11 later on. >> >> That is what it sounded like from the others, so it's what I'm going >> with. We'll see how on track I can stay. > > I've been following this discussion and I think I finally have something > to contribute. After K&R2, there's a very good book /Deep C Secrets/ by > Peter Van der Linden which I think is a great second book on C. > > If you're working in a Linux/Unix environment, then 2 excellent 3rd and > 4th books are K&Pike /The Unix Programming Enviroment/ and Axel Schreiner > /Curses, Lex, and Yacc/. Those sound familiar. Maybe I nabbed one (or more) of them in one of the various *nix humblebundles. > >> > I think some examples in K&R2 use "implicit int", and as I recall that's >> > addressed in the errata. Always declare and define functions with an >> > explicit return type. >> >> So far I haven't run across that, but I'm only in chapter 1 still. >> Working through slow / rereading the sections a few times so that it >> sticks. >> >> Honestly, a lot of the syntax is already starting to feel familiar >> again. But I've only read through §1.9 so far ... really have to go >> back and do the exercises -- kinda hard to do them on the bus. > > For that I suggest pencil and paper. I usually prefer pens, but pencil > makes fewer ugly blotches when the bus hits a bump or taps the brake. > It's like highschool all over again - finish that homework before I get to class :) -- |_|O|_| Registered Linux user #585947 |_|_|O| Github: https://github.com/dpurgert |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5 4AEE 8E11 DDF3 1279 A281
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2018-05-04 13:31 +0000 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <slrnpeoo69.31ka.grahn+nntp@frailea.sa.invalid> |
| In reply to | #129867 |
On Fri, 2018-04-27, Keith Thompson wrote: ... > In my opinion, you can get a good start learning the language from K&R2 > (if you have some existing programming experience). You can pick up the > changes made by C99 and C11 later on. IMO, there are some C99 features you want to use from the very start: - Declarations aren't limited to the beginning of the block (so you can use const more, and you're not punished for introducing temporaries for readability). - Inline functions (so you can put code in header files, and are less tempted to write long macros). They affect the structure of your code more than some other C99 additions. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | luser droog <luser.droog@gmail.com> |
|---|---|
| Date | 2018-05-04 17:19 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <b947582c-7a8b-49c4-9cd5-3d0367c52dd5@googlegroups.com> |
| In reply to | #130163 |
On Friday, May 4, 2018 at 8:32:02 AM UTC-5, Jorgen Grahn wrote:
> On Fri, 2018-04-27, Keith Thompson wrote:
> ...
> > In my opinion, you can get a good start learning the language from K&R2
> > (if you have some existing programming experience). You can pick up the
> > changes made by C99 and C11 later on.
>
> IMO, there are some C99 features you want to use from the very start:
>
> - Declarations aren't limited to the beginning of the block (so you
> can use const more, and you're not punished for introducing
> temporaries for readability).
>
> - Inline functions (so you can put code in header files, and are less
> tempted to write long macros).
>
> They affect the structure of your code more than some other C99
> additions.
>
Agree. But I'd add a few more to the list. I /love/ compound literals
and designated initializers.
Compound literals let you create struct and union and other complicated
objects in the middle of expressions. Often this can eliminate the need
for a variable and simplify the function overall (nb. I said 'often' not
'always'). Esp, things like a string literal of wchar_t or some other
exotic character type.
Designated initializers let you specify which member gets the value.
For unions, it's a total life safer. For structs, it's still super
nice. And for things like sparse arrays, fuggetaboutit. Hands down,
flat out, double plus good.
Coupled with a macro, I've used these recently for a super-quick and
super-dirty object-oriented style.
typedef struct parser *parser;
typedef struct result *result;
typedef result (*handler)( parser p, char *input );
/* A parser is a tree whose leaves are parse_term(), parse_fail(),
and parse_succeed() nodes. */
struct parser {
handler test;
parser a, b;
int c;
};
/* A parser returns a list of results. A NULL pointer indicates
no results, ie. failure. */
struct result {
result next;
int length_matched;
};
#define new_function_for_(type) \
type new_##type ( struct type input ){ \
type local = calloc( sizeof *local, 1 ); \
return local ? ( *local = input ), local : local; \
}
new_function_for_(parser)
new_function_for_(result)
If you have this kind of setup, then the designated initializers
can be used like named parameters in calls to the new* functions.
new_result( (struct result){ .next = NULL, .length_matched = 0 } );
new_parser( (struct parser){ .test = parse_fail } );
new_parser( (struct parser){ .test = parse_term, .c = c } );
Code from the clc post "Re: Parser Combinators" 6/16/17
https://groups.google.com/d/msg/comp.lang.c/BuwBXfpgN_M/4I4krY2PAgAJ
https://groups.google.com/d/topic/comp.lang.c/BuwBXfpgN_M/discussion
follow-ups to:
https://codereview.stackexchange.com/questions/166009/parser-combinators-in-oo-c
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2018-05-18 21:55 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <kfnr2m8i6qo.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #130163 |
Jorgen Grahn <grahn+nntp@snipabacken.se> writes: > On Fri, 2018-04-27, Keith Thompson wrote: > ... > >> In my opinion, you can get a good start learning the language from K&R2 >> (if you have some existing programming experience). You can pick up the >> changes made by C99 and C11 later on. > > IMO, there are some C99 features you want to use from the very start: > > - Declarations aren't limited to the beginning of the block (so you > can use const more, and you're not punished for introducing > temporaries for readability). > > - Inline functions (so you can put code in header files, and are less > tempted to write long macros). > > They affect the structure of your code more than some other C99 > additions. These surprise me because neither is either necessary or important. Functions in header files can be written as just regular static functions and typically they will be inlined anyway (and worrying about whether they are inlined is usually premature optimization). The idea that mixing declarations and statements adds a lot sounds like C++ bias (where using const initialization frequently has semantic implications, unlike C). Besides if it's important, just put in a new compound statement. There must be at least a dozen language features introduced in C99 that are more important than these two. Better to not even put these on the list, and emphasize writing short functions without falling into the trap of premature optimization.
[toc] | [prev] | [next] | [standalone]
| From | already5chosen@yahoo.com |
|---|---|
| Date | 2018-05-21 03:26 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <0c9de971-6b25-4b3d-b8d0-c2ab1df9efd1@googlegroups.com> |
| In reply to | #130794 |
On Saturday, May 19, 2018 at 7:56:09 AM UTC+3, Tim Rentsch wrote: > > The idea that mixing declarations and statements adds a lot sounds > like C++ bias (where using const initialization frequently has > semantic implications, unlike C). > The idea that mixing declarations and statements does not add a lot sounds like Torvaldsian bias.
[toc] | [prev] | [next] | [standalone]
| From | Tim Rentsch <txr@alumni.caltech.edu> |
|---|---|
| Date | 2018-06-14 03:00 -0700 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <kfn1sd9g015.fsf@x-alumni2.alumni.caltech.edu> |
| In reply to | #130915 |
already5chosen@yahoo.com writes: > On Saturday, May 19, 2018 at 7:56:09 AM UTC+3, Tim Rentsch wrote: > >> The idea that mixing declarations and statements adds a lot sounds >> like C++ bias (where using const initialization frequently has >> semantic implications, unlike C). > > The idea that mixing declarations and statements does not add a > lot sounds like Torvaldsian bias. Then apparently you have misunderstood my comment. I'm not opposed to mixing declarations and statements, in cases where it adds value. I'm not dogmatic about it either way.
[toc] | [prev] | [next] | [standalone]
| From | gazelle@shell.xmission.com (Kenny McCormack) |
|---|---|
| Date | 2018-12-26 06:43 +0000 |
| Subject | Mixing declarations and statements in C code (Was: [Solved] Need some help getting to my feet) |
| Message-ID | <pvv7vc$g7f$1@news.xmission.com> |
| In reply to | #131630 |
In article <kfn1sd9g015.fsf@x-alumni2.alumni.caltech.edu>, Tim Rentsch <txr@alumni.caltech.edu> wrote: >already5chosen@yahoo.com writes: > >> On Saturday, May 19, 2018 at 7:56:09 AM UTC+3, Tim Rentsch wrote: >> >>> The idea that mixing declarations and statements adds a lot sounds >>> like C++ bias (where using const initialization frequently has >>> semantic implications, unlike C). >> >> The idea that mixing declarations and statements does not add a >> lot sounds like Torvaldsian bias. > >Then apparently you have misunderstood my comment. I'm not >opposed to mixing declarations and statements, in cases >where it adds value. I'm not dogmatic about it either way. I think that it changes the flavor and look of C programs. It makes C look more like some new-ish thing - like we might see from MS or Sun or some company like that - rather than the gritty, low-level, assembler-like language that we all grew up with. I've gotten used to it (*) and kinda like it in my code, but again I do have to admit that it gives it a kinda new-age look. (*) Not that it is in reality some newfangled thing. It's been in the standard for 19 years, and allowable in gcc (the only compiler I use) for quite a while before that. P.S. It'd be interesting to know exactly *WHY* Linus don't like it... -- The randomly chosen signature file that would have appeared here is more than 4 lines long. As such, it violates one or more Usenet RFCs. In order to remain in compliance with said RFCs, the actual sig can be found at the following URL: http://user.xmission.com/~gazelle/Sigs/BestCLCPostEver
[toc] | [prev] | [next] | [standalone]
| From | Anton Shepelev <anton.txt@g{oogle}mail.com> |
|---|---|
| Date | 2018-12-26 19:02 +0300 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <20181226190200.579c2b3b60053c907d8c80d3@g{oogle}mail.com> |
| In reply to | #130915 |
already5chosen to Tim Rentsch:
>>The idea that mixing declarations and statements adds a
>>lot sounds like C++ bias (where using const initialization
>>frequently has semantic implications, unlike C).
>
>The idea that mixing declarations and statements does not
>add a lot sounds like Torvaldsian bias.
I prefer the old style because it better reflext the way I
think of an algorithm: declare me some variables and then
work with them. There are two benefits:
1. When a function grows so large that scrolling up to
the declaration sections becomes annoying, it is a
sure sign a refactoring is due. And it is a good
style that lets code plead the developer: "Refactor
me!".
2. Code flows smoother and has better rhythm. Actions
are not interrupted by declarations. Actions are
separate from declarations.
--
() ascii ribbon campaign - against html e-mail
/\ http://preview.tinyurl.com/qcy6mjc [archived]
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2018-12-31 18:01 +0000 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <slrnq2kmb3.1p1h.grahn+nntp@frailea.sa.invalid> |
| In reply to | #139083 |
On Wed, 2018-12-26, Anton Shepelev wrote: > already5chosen to Tim Rentsch: > >>>The idea that mixing declarations and statements adds a >>>lot sounds like C++ bias (where using const initialization >>>frequently has semantic implications, unlike C). >> >>The idea that mixing declarations and statements does not >>add a lot sounds like Torvaldsian bias. I'm not going to change anyone's mind after two decades, but some comments anyway: > I prefer the old style because it better reflext the way I > think of an algorithm: declare me some variables and then > work with them. That's tautological. You cannot change the way you write your code without changing the way you think, and the change in thinking is the whole point. I once did locals the C89 way, but moved to C99 and adjusted. I think it was an improvement -- not only because I write a lot of C++ too. > There are two benefits: > > 1. When a function grows so large that scrolling up to > the declaration sections becomes annoying, it is a > sure sign a refactoring is due. And it is a good > style that lets code plead the developer: "Refactor > me!". I dislike that argument, which pops up now and then (not just with C99 declarations). It's about making something worse on purpose, so you're forced to deal with it. I'd rather have a mild problem which I /don't/ have to deal with, so I can deal with all the other problems instead. > 2. Code flows smoother and has better rhythm. Actions > are not interrupted by declarations. Actions are > separate from declarations. See above: that's the way you think about it now, but to me it's a meaningless distinction. /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | Richard Damon <Richard@Damon-Family.org> |
|---|---|
| Date | 2018-12-31 17:16 -0500 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <gzwWD.177487$le.59699@fx14.iad> |
| In reply to | #139083 |
On 12/26/18 11:02 AM, Anton Shepelev wrote: > already5chosen to Tim Rentsch: > >>> The idea that mixing declarations and statements adds a >>> lot sounds like C++ bias (where using const initialization >>> frequently has semantic implications, unlike C). >> >> The idea that mixing declarations and statements does not >> add a lot sounds like Torvaldsian bias. > > I prefer the old style because it better reflext the way I > think of an algorithm: declare me some variables and then > work with them. There are two benefits: > > 1. When a function grows so large that scrolling up to > the declaration sections becomes annoying, it is a > sure sign a refactoring is due. And it is a good > style that lets code plead the developer: "Refactor > me!". > > 2. Code flows smoother and has better rhythm. Actions > are not interrupted by declarations. Actions are > separate from declarations. > In my view, the declaration doesn't break the flow of the action, but is just part of the action of declaring the variable as it is being initialized. float dist = fsqrt(x*x + y*y); The float isn't that distracting or interrupting (and putting them together makes the function shorter). Now, if you are creating a structure and needing to initialize all the pieces with separate statements, then you need a separate declaration statement, but you can initialize perhaps a lot of the structure in that statement.
[toc] | [prev] | [next] | [standalone]
| From | Bart <bc@freeuk.com> |
|---|---|
| Date | 2018-12-31 22:44 +0000 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <RZwWD.201178$%55.76713@fx10.am4> |
| In reply to | #139305 |
On 31/12/2018 22:16, Richard Damon wrote: > On 12/26/18 11:02 AM, Anton Shepelev wrote: >> already5chosen to Tim Rentsch: >> >>>> The idea that mixing declarations and statements adds a >>>> lot sounds like C++ bias (where using const initialization >>>> frequently has semantic implications, unlike C). >>> >>> The idea that mixing declarations and statements does not >>> add a lot sounds like Torvaldsian bias. >> >> I prefer the old style because it better reflext the way I >> think of an algorithm: declare me some variables and then >> work with them. There are two benefits: >> >> 1. When a function grows so large that scrolling up to >> the declaration sections becomes annoying, it is a >> sure sign a refactoring is due. And it is a good >> style that lets code plead the developer: "Refactor >> me!". >> >> 2. Code flows smoother and has better rhythm. Actions >> are not interrupted by declarations. Actions are >> separate from declarations. >> > > In my view, the declaration doesn't break the flow of the action, but is > just part of the action of declaring the variable as it is being > initialized. > > float dist = fsqrt(x*x + y*y); > > The float isn't that distracting or interrupting (and putting them > together makes the function shorter). > > Now, if you are creating a structure and needing to initialize all the > pieces with separate statements, then you need a separate declaration > statement, but you can initialize perhaps a lot of the structure in that > statement. > I have the opposite view. Not only do I like all declarations separate (and tidily tucked away at the top of a function, not even at the top of this block), but I like them to be only declarations, not also initialisations. (Except for array/struct initialisation.) There are quite a few issues with having declarations scattered anywhere, such as having to locate the declaration for name (which will involve scanning every line backwards to the top of a function). Or code mods which require a change in scope of variable so that its declaration needs to be moved (especially if you always want to smallest possible scope). When there is a group of related variables, it is better to declare them together, as this gives useful information, compared with declaring each at first use. But mainly, it just spoils the lines of the code. What the executable code does is one thing, the metadata about the types of the variables involved is another. (In my two main languages which have the same syntax, one requires static type declarations, the other doesn't. Porting between the two is easier when the declarations are out of the way.) -- bart
[toc] | [prev] | [next] | [standalone]
| From | Ike Naar <ike@iceland.freeshell.org> |
|---|---|
| Date | 2019-01-01 19:14 +0000 |
| Subject | Re: [Solved] Need some help getting to my feet |
| Message-ID | <slrn3s3kq2nf0p.iod.ike@iceland.freeshell.org> |
| In reply to | #139307 |
On 2018-12-31, Bart <bc@freeuk.com> wrote: > There are quite a few issues with having declarations scattered > anywhere, such as having to locate the declaration for name (which will > involve scanning every line backwards to the top of a function). Often those declarations are not "scatterd anywhere", they are just a few lines above the point where the name is used so there is no need to scroll back to the top of the function.
[toc] | [prev] | [next] | [standalone]
Page 5 of 7 — ← Prev page 1 2 3 4 [5] 6 7 Next page →
Back to top | Article view | comp.lang.c
csiph-web