Skip to contentSkip to conversation

mipsel-gcc sick with #pragma?

DISCUSSION renwei 2 participants 2 messages Jul 28, 2002 MIPS

lore
Share & tools
lore

renwei

author
#0 lore raw

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.

#1 lore raw
Quoted 6 lines · renwei

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

gcc version 2.95.3 19991030 (prerelease)

Works fine with gcc 2.96-110.1 and gcc 3.1.1 20020717.

H.J.