[Xastir-Dev] Interesting compiler difference

Curt Mills, WE7U archer at eskimo.com
Fri Nov 28 12:26:38 EST 2003


On Fri, 28 Nov 2003, Chuck Byam wrote:

> On Wednesday 26 November 2003 09:51, Curt Mills wrote:
> << snip, snip >>
> > Turns out I did a boo-boo and put a variable declaration a few lines
> > down in a block, after some other executable code.  Gcc 3.3 didn't
> > care and compiled it anyway.  The older gcc did.  I did a tkdiff
> > this morning on that file to see what the differences where.
> >
> > Anyone else run across this sort of thing?

One sentence above should have been:  "The older gcc didn't."


> The compiler treats anything defined inside a codeblock as local to that 
> block.  This can be very handy and the souce of frustration as well.  Note 
> that a codeblock also includes if/do while, etc.  This also helps enforce the 
> "suggestion" that definitions should be made as close to the point of use as 
> possible.

I'm aware of the issues you presented.  The issue I was presenting
(but not clearly) was that the newer gcc-3.3 allows you to intermix
the declarations directly in the code (doesn't have to be at the
beginning of a block), while older gcc's don't allow this.  This
appears to be a C99 requirement.  

In my case I was doing a cut-and-paste, and ended up with executable
code above some declarations by mistake.  It compiled fine on SuSE
8.2, but not on 7.3.  Unfortunately I had already committed it to CVS
and had done a development release by then, so it broke it for
everyone running a GCC less than 3.3.

I tried some of the compiler flags that supposedly made gcc-3.3
compatible with older C specs, but they didn't solve the problem.  I
need a flag that will make "mixed declarations and code" illegal in a
compile, or at least flag a warning for me.  That would help keep the
Xastir code-base compilable on more systems.  Judging by some of the
messages I read on the 'net, it's a problem for quite a few projects
right now that there is no such flag.

I think the only solution right now is to keep an older compiler
around and do a test compile of Xastir on it periodically.  I don't
like that solution.  I also don't want to rely on users telling me
that it doesn't compile anymore.  :-(

-- 
Curt, WE7U.				archer at eskimo.com
http://www.eskimo.com/~archer
  Lotto:  A tax on people who are bad at math. - unknown
Windows:  Microsoft's tax on computer illiterates. - WE7U.
The world DOES revolve around me:  I picked the coordinate system!"





More information about the Xastir-dev mailing list