public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* proper c source coding standard - style changes?
@ 2009-08-30 14:56 David C. Rankin
  2009-08-30 16:12 ` Philip Herron
  0 siblings, 1 reply; 5+ messages in thread
From: David C. Rankin @ 2009-08-30 14:56 UTC (permalink / raw)
  To: gcc

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). 

-- 
David C. Rankin, J.D.,P.E.
Rankin Law Firm, PLLC
510 Ochiltree Street
Nacogdoches, Texas 75961
Telephone: (936) 715-9333
Facsimile: (936) 715-9339
www.rankinlawfirm.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-08-30  6:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-30 14:56 proper c source coding standard - style changes? David C. Rankin
2009-08-30 16:12 ` Philip Herron
2009-08-30 18:42   ` David C. Rankin
2009-08-30 20:25     ` Dave Korn
2009-08-30 22:47       ` David C. Rankin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).