Subject: Re: GCC to retire VAX support!?
To: Lord Isildur <mrfusion@uranium.vaxpower.org>
From: Jason R Thorpe <thorpej@wasabisystems.com>
List: port-vax
Date: 06/20/2002 09:11:17
On Thu, Jun 20, 2002 at 10:52:57AM -0400, Lord Isildur wrote:

 > i find this very hard to believe. C, either ansi ro K&R (my personal 
 > preference) is _extremely_ flexible. what kind of thing can one not do in 
 > C that one can in gcc, and i dont mean things for which there would be 
 > five lines of C and just one bit of gccism shorthand for... i am 
 > convinced that _most_ of the gnu-isms , not just in gcc but in e.g. gnu 

Well, let's see...

Here's one:

	struct on_disk_structure {
		uint16_t foo1;
		uint32_t foo2;
		uint16_t foo3;
		uint16_t foo4;
	} __attribute__((__packed__));

That is a GCC extension.  In fact, in order to specify any type of
structure packing, you have to use an extension, no matter which compiler
you use.  The ability to specify packet structures is extremely
important when dealing with things that land on disk or go out a network
cable.

Here's another:

int global;

void initfunc(void) __attribute__((__constructor__));

void
initfunc(void)
{
	global = 0xdeadbeef;
}

void finifunc(void) __attribute__((__destructor__));

void
finifunc(void)
{
	global = 0;
	abort();
	/* now examine "global" in the core file */
}

int
main(int argc, char *argv[])
{
	printf("0x%x\n", global);
	exit(0);
}

The ability to specify constructor/destructor functions for modules is
incredibly useful, esp. for use by the system libraries.

Here's another:

void	printflikefunc(const char *, ...)
	    __attribute__((__format__(__printf__,1,2)));

int
main(int argc, char *argv[])
{
	printflikefunc("hello world\n", argc);
	printflikefunc("%s %s");
}

The ability of the compiler to check printf format strings against the
arguments actually passed and issue warnings if they don't match up is
not only useful, but important during code security audits (remember
the format string exploits that happened a year or two ago?).

-- 
        -- Jason R. Thorpe <thorpej@wasabisystems.com>