开发者

Are macro definitions compatible between MIPS and Intel C compiler?

开发者 https://www.devze.com 2023-01-01 21:16 出处:网络
I seem to be having a problem with a macro that I have defined in a C program. I compile this software and run it sucessfully with the MIPS compiler.

I seem to be having a problem with a macro that I have defined in a C program.

I compile this software and run it sucessfully with the MIPS compiler.

It builds OK but throws the error "Segmentation fault" at runtime when using icc.

I compiled both of these on 64 bit architectures (MIPS on SGI, with -64 flag and icc on an intel platform).

Is there some magic switch I need to use to make this work correctly on both system? I turned on warnings for the intel compiler, and EVERY one of the places in my program where a macro is invoked throws a warning. Usually something along the lines of mismatched types on the macro's parameters (int to char *) or some such thing.

Here is the offending macro

 #define DEBUG_ENTER(name) {tdepth++; 
 if(tnames[tdepth] == NULL) tnames[tdepth] = memalign(8, sizeof(char)*MAXLEN);
 strcopy(tnames[tdepth],name);
 FU_DEBUG("Entering \n");}

This basically is used for debugging - printing to a log file with a set number of tabs in based on how m开发者_开发知识库any function calls there are. (tdepth = tab depth)

I did some checking around in man pages. it seems like memalign is only supported on IRIX. This may be my problem. I am going to track it down.


This might have to do with the system's "endianness." Looking here it seems that MIPS has switchable endianness. I'm not sure if you are using the correct endianness already, but if you aren't, you will DEFINATELY have problems.


This might be a byte order issue. MIPS can be big endian but intel is little endian.


It sounds like the array tnames is an array of int. If you're assigning pointers to it, it should be an array of a pointer type - in this case probably char * is appropriate.

(Also, strcopy() isn't a standard function - are you sure you don't mean strcpy()?)

0

精彩评论

暂无评论...
验证码 换一张
取 消