-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

David C. Rankin wrote:
> Listmates,
>
> First post, and more of a curiosity than a problem. Years ago I
> worked extensively with c, fortran, etc. (late '80s, early 90s). I
> do my own office infrastructure/networking/groupware, etc. all with
> linux and open source software. Occasionally that requires me to
> dust off my programming tools to tweak this or that to work in my
> setting. Most recently a bit of c with the mysql connector. In
> doing so I have noticed one big change to the way source files are
> now formatted.
>
> When I grew up doing this your source files and functions would
> normally be laid out in this order:
>
> #include <headerfile.h>
>
> void function ();    // function headers defs int *function ();
>
> int main () { do something; return 0; }
>
> void function () { stuff; }
>
> int *function () { stuff; }
>
> Now I see through much of the glibc documentation and other sources
> a layout like this:
>
> #include <headerfile.h>
>
> void function () { stuff; }
>
> int * function () { stuff; }
>
> int main () { do something; return 0; }
>
> And, yes, I know it doesn't matter to the compiler, but as I said I
> was curious. Has there been some type of recommended standard for
> doing it in this way, or is it just more of a some people like
> chocolate ice cream versus vanilla issue? In the olden days, IIRC,
> the logic was that you wanted to see the most important part of
> your code up top -- the main function, without having to wade
> through all the function bodies before you got to it. With the new
> layout, you don't have to worry about an additional function def up
> top with eliminates the chance of typos and makes changes easier.
> So I see the benefits of both.
>
> Also, if this is some type of flame war issue like vi/emacs, I
> apologize in advance, I am not aware of its sensitivity, I'm just
> curious and like to follow the "recommended" standard in case
> somebody has to read my code in the future. Thanks.
>
> All I'm looking for is either a (yep there was a new
> recommendation, here's the link) or a (it's a chocolate or vanilla
> thing).
>
I take it you haven't done much programming, take a look at any
project on the net they all have their own code formatting preferences
for whatever helps _you_ read your code. This should probably be moved
to gcc-help...

A benefit of using the bottom formating is you don't need to keep
prototypes for the extra functions if they are being called by main.

Try not to ask questions like this in GCC, GCC-help is for help on
using gcc etc.

- --Phil
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkqZ2b0ACgkQAhcOgIaQQ2GJ4QCfXCtFIHeDfYIhoVAbMQNiEV/P
WVIAn2/61h/MwEb0f4LTdVnnZXwarbNo
=6paS
-----END PGP SIGNATURE-----

Reply via email to