[ale] gcc programming

Danny Cox danscox at mindspring.com
Sun Jan 23 14:41:06 EST 2005


Geoffrey,

On Sat, 2005-01-22 at 21:52 -0500, Geoffrey wrote:
> This is probably as good a place as any I suspect.

	Agreed!  Not to sound like a troll, but I'd submit that this forum is a
better place for programming questions than other topics attempted here.
"Troll, troll, troll, troll,..." <sung to the tune of "Spam, spam, spam,
spam....".

> You'll likely want to write the debug info to standard error and capture.
> 
> Here's how I do it in C so that I can track where the data was spit out:
> 
> (void)fprintf(stderr, "%s %d: %s\n", __FILE__, __LINE__, debugdata);

	I use this a lot, but there a new gcc-only construct "__FUNCTION__",
used like "__FILE__", which will substitute the name of the current
function as a quoted string.

	Just FYI, and as a matter of both style and later convenience, I write
my functions with the scope and type on a separate line like this:

static char *
foo (char *bar)
{
}

So that a search of:

	grep '^foo' *.c

will return the definition (or is that declaration, I can never remember
which is which ;-) of the function itself, none of it's calls.

-- 
kernel, n.: A part of an operating system that preserves the
medieval traditions of sorcery and black art.

Danny



More information about the Ale mailing list