C compilation questions
I've agreed to adopt meschach, and have been trying to recompile it.
It hasn't been recompiled for a year-and-a-half, and specified that it
requires egcc rather than gcc. However, I suspect that since that time egcc
has been merged into gcc proper (they took over development, didn't they?),
and I think I have some ansi C questions to resolve. I've currently got gcc
2.95.2-20. The previous compilation must have been done while gcc 2.7.2
reigned, or something, and egcc is no longer available as a separate package.
Now there are two issues I'd like to ask about, one of which halts
compilation.
The first problem comes from a typedef using a struct. meschach wants to
define complex numbers using (from zmatrix.h):
typedef struct {
Real re, im;
} complex;
(Real is defined elsewhere as double).
This generates the compiler warning:
zmatrix.h:41: warning: useless keyword or type name in empty declaration
zmatrix.h:41: warning: unnamed struct/union that defines no instances
At the point where the struct is actually being used (the or .re .im field is
referred to), I find the error:
zmachine.c:62: request for member `re' in something not a structure or union
zmachine.c:62: request for member `im' in something not a structure or union
and compilation ceases.
If I instead use
typedef struct {
Real re, im;
} complexNum;
then it appears to compile OK, but this is a poor solution since I'd have to
then change all references from type complex to type complexNum.
So the problem seems to be some conflict over the name "complex", but I
don't understand what the conflict is exactly. gcc supports the keyword
"__complex__" via complex.h, but that's different to just defining
"complex", isn't it? Any ideas?
================
The second problem seems to be one of policy. I get a warning:
In file included from /usr/include/math.h:33,
from lufactor.c:37:
/usr/include/bits/huge_val.h:37: warning: HUGE_VAL' redefined
machine.h:216: warning: this is the location of the previous definition
This happens because the source file in question has:
#include "matrix.h"
#include <math.h>
Meschach header file matrix.h defines HUGE_VAL if it isn't already defined,
while the standard header math.h also defines it. This can of course be
resolved by simply changing the order:
#include <math.h>
#include "matrix.h"
So my question here is how much of a problem is this? Should it be (or is
it) official policy somewhere that standard headers should always be given
before local headers?
Thanks for any words of wisdom,
Drew
--
PGP public key available at http://dparsons.webjump.com/drewskey.txt
Fingerprint: A110 EAE1 D7D2 8076 5FE0 EC0A B6CE 7041 6412 4E4A
Reply to: