Search code examples
cmacrosmipsicc

Are macro definitions compatible between MIPS and Intel C 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 many 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.


Solution

  • 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.