linux-mips
[Top] [All Lists]

mipsel-gcc sick with #pragma?

To: linux-mips@oss.sgi.com
Subject: mipsel-gcc sick with #pragma?
From: renwei <renwei@huawei.com>
Date: Sun, 28 Jul 2002 16:01:41 +0800
Sender: owner-linux-mips@oss.sgi.com
hi, 

  I have some mipsel-linux-gcc on my i386 pc
to compile something , just like this:

/***********   begin ************/

#include <stdio.h>
#include <stdlib.h>
#define pack warn  

#pragma pack(1)

typedef  struct tagHDP_IPPrefix1
{
    unsigned long ulIPPrefixNum;     
    unsigned char pucData[1];  b
}HDP_IPPrefix_S1;

typedef  struct tagHTP_Packet_TLV1
{
    unsigned short usType;              /* Type */
    unsigned short usLen;               /* Length */
    unsigned char  pucValue[20];         /* Value */
}HTP_Packet_TLV_S1;

#pragma pack(  )

void * test1(HTP_Packet_TLV_S1   stNewTLV)
{
    HDP_IPPrefix_S1      *pstIPPrefix    = 0; 
    pstIPPrefix = ( HDP_IPPrefix_S1 * )(stNewTLV.pucValue); 
    pstIPPrefix->ulIPPrefixNum = 0; 
    pstIPPrefix->ulIPPrefixNum += stNewTLV.usType * 2;
    return  pstIPPrefix;

}

/************* end of the file*************/

I compile it with :
mipsel-linux-gcc -c -O2 test.c -o test.o
but the result:
/tmp/ccMTigfE.s: Assembler messages:
/tmp/ccMTigfE.s:22: Error: illegal operands `sw'

compile with this:
mipsel-linux-gcc -c test.c -o test.o

will sucess.


the gcc manual says the use of #pragma is not good, 
so it doesn't support it.
I think  line 
#pragma pack(1)

is of no use , but it seems not the case.

my cross gcc is :
`    
 mipsel-linux-gcc -v

gcc version 2.95.3 19991030 (prerelease)

that's really a bug , I think.

should I upgrade my toolchain?  does the mipsel-gcc 3.1 ok at this case?

who knows the way to fix this?
                                        
            thanks.







<Prev in Thread] Current Thread [Next in Thread>