Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | BartC <bc@freeuk.com> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Forward declarations |
| Date | 2015-11-12 09:58 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <n21nnb$dus$1@dont-email.me> (permalink) |
| References | <868218d9-3441-42d4-8006-7684e9f034fa@googlegroups.com> <n1vjru$45r$1@dont-email.me> |
On 11/11/2015 14:40, David Brown wrote: > On 10/11/15 23:20, Rick C. Hodgin wrote: >> What's the standard C compiler command line switch allowing one to >> turn off the REQUIREMENT of having forward declarations in a source >> file here in 2015 when hard disk space, memory, and CPU power render >> the requirement absolutely and completely unnecessary? > Hyperbole aside, there are several reasons for having declarations in > addition to definitions. > > It is definitely the case that declarations in advance of usage make it > easier to implement a compiler - without them, the compiler would have > to build up bits of its parse trees as it goes along, filling in the > missing bits when it has more information. That would only be the case, for a language with C-like syntax, for things such as typedefs, where you need to know that something is the name of a type in order to easily parse what follows. That is not necessary for function names (nor label names, but C has already figured that one out). Variables can be declared later on too, but C requires them to be declared before use, and I prefer that anyway.) > However, it would not be hard to have a compiler that first ran through > the pre-processed file and sorted the file into type definitions, > variable declarations, variable definitions, function declarations, then > function definitions. For each function definition, it could create a > forward definition and squeeze that in before the function definitions, > and then compile the whole lot. Off-hand I cannot think of any reason > why that might not work, but I would want a good deal more thought and > opinion before calling it problem-free. I've done that (in a source-to-source converter) and it appears to work. It neatly segregates module-scope or exported local typedefs, local variables, local function prototypes, imported versions of all those, followed by local or exported function definitions. > As for scaling, and cpu power and memory, then it is clear that you > haven't worked on large-scale projects. There are plenty of projects > that take /hours/ to compile and link when doing a full re-build. (I don't think any project of mine would have got to the point where a development cycle would take hours. I would first explore what is possible with things such as dynamic linking, so that different parts can be developed separately, and the off-loading of as much functionality as possible onto interpreted languages which don't have a build time. If that wasn't enough I would look at speeding up the tools as much as possible: writing a linker isn't that hard for example. But then, it is also possible that some projects are unnecessarily complex, and I wouldn't have allowed that to happen either!) -- Bartc
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-10 14:20 -0800
Re: Forward declarations jacobnavia <jacob@jacob.remcomp.fr> - 2015-11-10 23:38 +0100
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-10 15:00 -0800
Re: Forward declarations Ian Collins <ian-news@hotmail.com> - 2015-11-11 12:24 +1300
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-10 15:53 -0800
Re: Forward declarations gazelle@shell.xmission.com (Kenny McCormack) - 2015-11-11 00:01 +0000
Re: Forward declarations Ian Collins <ian-news@hotmail.com> - 2015-11-11 13:46 +1300
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-10 21:05 -0800
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-11 00:21 +0000
Re: Forward declarations Lőrinczy Zsigmond <zsiga@nospam.for.me> - 2015-11-11 10:16 +0100
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-11 07:19 -0800
Re: Forward declarations David Brown <david.brown@hesbynett.no> - 2015-11-11 15:40 +0100
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-11 07:21 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-11 07:23 -0800
Re: Forward declarations David Brown <david.brown@hesbynett.no> - 2015-11-11 16:29 +0100
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-11 07:31 -0800
Re: Forward declarations Nick Bowler <nbowler@draconx.ca> - 2015-11-13 18:20 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-13 10:39 -0800
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-13 19:40 +0000
Re: Forward declarations Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-14 11:42 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-14 12:32 -0800
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 00:15 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-14 16:34 -0800
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 01:54 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-14 18:00 -0800
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 02:13 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-14 18:26 -0800
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 02:34 +0000
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-15 11:11 +0000
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 02:36 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-14 19:25 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-14 19:37 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-14 20:11 -0800
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 10:36 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 06:16 -0800
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-15 14:44 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 09:41 -0800
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 18:26 +0000
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-15 18:42 +0000
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 18:53 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 12:58 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 12:49 -0800
Re: Forward declarations Ian Collins <ian-news@hotmail.com> - 2015-11-16 10:01 +1300
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-15 14:54 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 09:53 -0800
Re: Forward declarations Keith Thompson <kst-u@mib.org> - 2015-11-15 10:36 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 12:56 -0800
Re: Forward declarations Ian Collins <ian-news@hotmail.com> - 2015-11-16 10:04 +1300
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 13:11 -0800
Re: Forward declarations Ian Collins <ian-news@hotmail.com> - 2015-11-16 10:25 +1300
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 13:37 -0800
Re: Forward declarations Tim Rentsch <txr@alumni.caltech.edu> - 2015-11-15 13:13 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 13:16 -0800
Re: Forward declarations David Brown <david.brown@hesbynett.no> - 2015-11-16 00:23 +0100
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 16:20 -0800
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-16 00:47 +0000
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-16 01:28 +0000
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-16 01:57 +0000
Re: Forward declarations Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-15 21:15 -0500
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-16 11:05 +0000
Re: Forward declarations Eric Sosman <esosman@comcast-dot-net.invalid> - 2015-11-16 10:18 -0500
Re: Forward declarations Richard Heathfield <rjh@cpax.org.uk> - 2015-11-16 06:44 +0000
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-16 11:26 +0000
Re: Forward declarations David Brown <david.brown@hesbynett.no> - 2015-11-16 12:43 +0100
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-16 12:20 +0000
Re: Forward declarations David Brown <david.brown@hesbynett.no> - 2015-11-16 14:38 +0100
Re: Forward declarations Ben Bacarisse <ben.usenet@bsb.me.uk> - 2015-11-16 13:26 +0000
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-16 13:53 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-15 18:12 -0800
Re: Forward declarations pa@see.signature.invalid (Pierre Asselin) - 2015-11-12 01:54 +0000
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-12 02:08 -0800
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-12 09:58 +0000
Re: Forward declarations John Bode <jfbode1029@gmail.com> - 2015-11-17 14:46 -0800
Re: Forward declarations "Rick C. Hodgin" <rick.c.hodgin@gmail.com> - 2015-11-17 14:59 -0800
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-17 23:35 +0000
Re: Forward declarations BartC <bc@freeuk.com> - 2015-11-17 23:40 +0000
Re: Forward declarations Keith Thompson <kst-u@mib.org> - 2015-11-17 19:48 -0800
Re: Forward declarations glen herrmannsfeldt <gah@ugcs.caltech.edu> - 2015-11-18 01:04 +0000
csiph-web