#pragma pack compilation errors on Solaris 7

#pragma pack compilation errors on Solaris 7

Post by bev.. » Thu, 13 May 1999 04:00:00



Hi there,

I am getting some very strange errors using #pragma pack on Solaris 7,
and can't for the life of me see what I am doing wrong. The code that
I am compiling compiles and runs okay on Solaris 2.x. I am compiling C++
code using Sun's CC compiler (oddly enough, all the c files that I
compile up with the cc compiler, using exactly the same #pragma
directives, works. I am using Visual WS C++/Sparc 3.0 on Solaris 7
(whereas I was using WS Compiler C/C++/SPARC 4.2 on Solaris 2.x). On
Solaris 7, I am also running in 32-bit mode (although I don't think this
should make a difference) - I haven't yet had a chance to try it in
64-bit mode. Is there anyone out there that can give me some idea of what
I might be doing wrong - or is there a problem with this version of
compiler on Solaris 7.

The following error messages occur when I try to compile the code in
question:

 line 250: Error: Syntax error in pragma.
 line 250: Error: Missing ')' in #pragma.

Line 250 reads: #pragma pack()

This line, as far as I am aware, should remove the effects of the
previous pack(1) line. It seems that the pack pragma does not like
having no arguments, even though all the doc that I have says this is
valid. So, why isn't this working!?

Any help would be very much appreciated. Many thanks in advance,

      Blake Evans-Pritchard

--
All opinions expressed above are my own. They may not necessarily
be those of my employer, IBM.

 
 
 

1. SIGBUS error using #pragma pack

I have the following piece of code a program:

#pragma pack(2)
typedef struct myStruct {
   unsigned a       :8
   unsigned b       :4
   unsigned c       :3
   unsigned d       :1
   ...
   ...
   unsigned z        :11

All the struct members uses a total of 10 bytes, but 12 bytes of memory
was being allocated for the struct (hence the need for the #pragma
command).  Whenever I try to read a struct member (i.e. myStruct.d), I
get a SIGBUS error (ADRALN - invalid address alignment).  How can I fix
this?  The program is compiled using CC on a Solaris 7 system.
--
-Dennis
Remove <!spam> from reply-address for proper delivery

2. Please help me with my IPChains rules...

3. Solaris C++4.0.1 doesn't support #pragma pack(n)!!?

4. New job for me.

5. sunos pragma pack() doesnt work

6. RH 6.1 After Install boots to command prompt not Graphical Prompt???

7. #pragma pack(1)

8. Multiple X servers

9. Alignment Problem (#pragma pack (1) )

10. #pragma pack

11. Problem with #pragma pack()

12. Using #pragma pack(n)

13. Please help, pragma pack.