The Design of Software (CLOSED)

A public forum for discussing the design of software, from the user interface to the code architecture. Now closed.

The "Design of Software" discussion group has been merged with the main Joel on Software discussion group.

The archives will remain online indefinitely.

Dependency breaking tactic breaks in some compilers

I am porting a C project to a new compiler (to gcc).

In the current project, we make much use of this sort of thing in .h headers:

int function3(struct bar *, struct foo *);

And sometimes this:

extern struct bar set_o_bars[];

This all compiles without requiring the header to do a:

 #include "bar.h"

 - since we only use a bar * in function3() and so defining bar in the header is now not necessary. The include "bar.h" just goes in the .c file only. This reduces dependencies a lot and is a good practice.

But the extern undefined array thing doesn't work in gcc, even though it works in the older compiler. Is this some special thing that is not supported by all compilers? Do I need to turn of strict ANSI something or enable or pragma my way into having it work?

Another thing that doesn't work in gcc is this deal:

static const double pi = 3.141592653;

double numbers[] = {
 0.0,
 1.0,
 2.0,
 pi,
 4.0
};

The old compiler is able to handle this because pi is a const. But gcc doesn't like it - says I am trying to initialize with a non-constant. What gives?

Thanks for any insights.
Scott
Wednesday, November 16, 2005
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics
 
Powered by FogBugz