Operating System - Linux
1819928 Members
3094 Online
109607 Solutions
New Discussion юеВ

HP_ALIGN and gcc/g++ compiler

 
SOLVED
Go to solution
Craig Smith_13
Frequent Advisor

HP_ALIGN and gcc/g++ compiler


I have some legacy data/file structures that require the HP_ALIGN HPUX_WORD pragma. Will gcc/g++ (version 3.4.2) really understand the HP specific pragma, or I'm I just lucky with the data structure aligning properly?

I wrote a small test program using the pragma in a .h file included in a .c file that reads a n old file, then created a simple .cpp file that calls the function to read the file:
gcc -g -o test test.cpp my_c.c

Background:

I have Qt 4.1x and tried to compile it with aCC version 3.30, but receive errors.... Trolltech believes it a compiler bug. In any case, I can compile it with gcc, therefore I do not want to mix and mash a program using two different compilers.


Thanks.
8 REPLIES 8
Steven E. Protter
Exalted Contributor

Re: HP_ALIGN and gcc/g++ compiler

Shalom,

I don't think gcc is going to handle this code.

Sounds like you need an HP compiler for this, which will cost you a few shekels or dollars local currency.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Craig Smith_13
Frequent Advisor

Re: HP_ALIGN and gcc/g++ compiler

Hi Steven,

Thanks for the response. I just did an inventory.xml and checked for patches for my aCC v3.30. Downloading them now.

In the mean time, I'm able to compile my test program with gcc and it seems to work (reading the files containing the data structures). Didn't know if the gcc version for HPUX somehow recognizes the HP specific pragmas or it was just a fluke.

I included a the sample program.

Regards,
Craig.
A. Clay Stephenson
Acclaimed Contributor

Re: HP_ALIGN and gcc/g++ compiler

HPUX_WORD is an extremely old data alignment model; it was the native packing for the old 300/400 series boxes. It specified that int's and float's be aligned on 2-byte boundaries; doubles on 4-byte boundaries; and structs on at least 2-byte boundaries. It's going to be a bit tricky to get the correct alignment in every case but that is a direct result of the legacy code expecting binary data to always be aligned the same way. You may have to specify the packing and possibly add filler fields to some structs. Silly me, even 20 years ago, I always added filler to align my structs on 8-byte boundaries; it wasted space then but it sure ported across machine/OS boundaries easily.

You are running a very old version of aCC so my first action would be to come up to the latest version and then to check for patches for it as well.

I've never had any problems compiling/running Qt with aCC or gcc but I don't use gcc on HP-UX boxes.
If it ain't broke, I can fix that.
Craig Smith_13
Frequent Advisor

Re: HP_ALIGN and gcc/g++ compiler


I'm surprised that it works with gcc, not sure why and whether to trust it. I could compile the C code into object code or a library with HP C or aCC and just include it with the gcc compilation.

Used HP's depot evaluation tool and downloaded the depots it listed for aCC 3.3, but it appears that not all dependencies got listed, need to do it manually. Blew budget on Qt, aCC purchase will have to wait.


The legacy data structures were used in a commerical product that I need to stay compatible with. It was developed on the 300/400, as was my initial software and used the push/pop when we went to 700s.

My first Unix program was developed on a 300 (with curses) interfacing with GPIO tape drives :-).


Steve Ellcey
Valued Contributor
Solution

Re: HP_ALIGN and gcc/g++ compiler

I don't believe GCC ever understood the HP_ALIGN pragma. I certainly don't see any sign of it in the current GCC sources. I don't have 3.4 sources, the latest GCC is 4.1.1. I think you are getting lucky, and if your luck runs out and you need to try and get a specific alignment with GCC you could try using the alignment attribute in GCC to mimic what the HPUX_WORD alignment was doing.
Dennis Handly
Acclaimed Contributor

Re: HP_ALIGN and gcc/g++ compiler

aC++ has never supported HP_ALIGN. In fact on IPF, that pragma isn't supported in C anymore. You'll have to use the pack pragma.

A.03.30 is over 5 years old and not supported. It's only patch is A.03.31, PHSS_25170. The latest PA version is A.03.70.
A. Clay Stephenson
Acclaimed Contributor

Re: HP_ALIGN and gcc/g++ compiler

The good news is that you are going to love Qt.
If it ain't broke, I can fix that.
Craig Smith_13
Frequent Advisor

Re: HP_ALIGN and gcc/g++ compiler

Thanks for all the replies.