Operating System - Linux
1829717 Members
2020 Online
109992 Solutions
New Discussion

hp-ux 11.23 ia64 gcc4 including <net/if.h> not possible

 
SOLVED
Go to solution
Cadetg Marco
New Member

hp-ux 11.23 ia64 gcc4 including <net/if.h> not possible

Hi@all!

What i made:
including #include
compile with gcc4.0.2
result is : /usr/include/machine/sys/getppdp.h:65: error: array type has incomplete element type

As far as I know gcc4 will not compile constructs like the one in /usr/include/machine/sys/getppdp.h:65. But then it is not possible for me to compile something that includes This is a really stupid behavior of gcc.

Does someone know a workaround without dowgrading gcc4 to gcc3.x?

THX a lot for every help on this!!!
5 REPLIES 5
rick jones
Honored Contributor
Solution

Re: hp-ux 11.23 ia64 gcc4 including <net/if.h> not possible

Ah, gcc's fondness for "massaging" include files at work again?-)

Apart from the downgrade you don't want to do, you might consider the HP compilers.

Apart from that, you might extract just those parts of net/if.h you need and put them into your own include file. Not the most "robust" of things to do, but it might get you where you want to go.

WRT the HP compilers, if this is for a one-shot kind of thing, there is www.testdrive.hp.com.

And if you've not already done so, a bug report against gcc would seem to be in order?
there is no rest for the wicked yet the virtuous have no pillows
Cadetg Marco
New Member

Re: hp-ux 11.23 ia64 gcc4 including <net/if.h> not possible

THX. Generally I think it is not really the best idea to just remove some parts of the library, but in this case I will try it out.
Cadetg Marco
New Member

Re: hp-ux 11.23 ia64 gcc4 including <net/if.h> not possible

I filled out a bug report at gcc bugzilla. But the error is in the system library. See:
getppdp.h:65:
extern union mpinfou spu_info[];
thats not valid ansi c code.

So I don't know who has to fix the problem. Because it is really an: array type has incomplete element type

If done a "workaround" by simply remove the brackets.
Steve Ellcey
Valued Contributor

Re: hp-ux 11.23 ia64 gcc4 including <net/if.h> not possible

I am not convinced that this is illegal C. The HP compiler takes it and GCC 3.X takes it. I think GCC 4.0.2 is looking at section 6.2.5 of the C standard which says you can't construct an array of an incomplete type but I don't think GCC should be trying to construct anything here so it should be OK as long as the type is defined completely before being used anywhere and it is.

Do you have the PR number for the GCC bugzilla report you submitted? I could not find it.

As for workarounds, rather than remove the brackets from the header file I would probably add the definition of mpinfou to your source file before the include. This definition is in /usr/include/sys/mp.h. Just including doesn't help because this file includes getppdp before it defines mpinfou and results in the same error.

Another way to fix it would be to modify the GCC specific sys/mp.h header file. GCC creates copies of system header files and you could tweak that instead of changing the real system header file.

If GCC 4.0.2 is installed in /opt/hp-gcc-4.0.2 on ia64-hp-hpux11.23 then the system header file copies would be in /opt/hp-gcc-4.0.2/lib/gcc/ia64-hp-hpux11.23/4.0.2/include. There is probably no sys/mp.h in there but you could copy /usr/include/sys/mp.h there and then move the definition of mpinfou to the front of that file to fix the problem. GCC will automatically pick up the modified header file.
Cadetg Marco
New Member

Re: hp-ux 11.23 ia64 gcc4 including <net/if.h> not possible

hi steve
:qoute:
I am not convinced that this is illegal C. The HP compiler takes it and
GCC 3.X takes it. I think GCC 4.0.2 is looking at section 6.2.5 of the
C standard which says you can't construct an array of an incomplete type...
:quote:
I don't know if you are right. The GCC4 has changed its behaviour in handling of such constructs of an array of an incomplete type. Thatswhy it works with GCC3.X but it doesn't work with GCC4.

See also http://gcc.gnu.org/ml/gcc/2005-02/msg00054.html

The Bugzilla number of my bugreport is 26189

I never wanted to change the system lib directly. I did it now like you suggested.