MIPS to ICC endian problem

This is a discussion on MIPS to ICC endian problem within the C Programming forums, part of the General Programming Boards category; Hi all. I have a program that I have been compiling using MIPS compiler. I have recently been tasked to ...

  1. #1
    Registered User
    Join Date
    Nov 2009
    Posts
    24

    MIPS to ICC endian problem

    Hi all. I have a program that I have been compiling using MIPS compiler. I have recently been tasked to port this to our new Intel system using icc.

    It compiles fine, but when I run it, I get "Segmentation fault" with no other info.

    Someone suggested it may be an endian problem. I turned on warnings and it seems like every one of my macro definitions has a problem.

    Here is an example of the first one I have come to:

    Code:
    #define DEBUG_ENTER(name) {tdepth++;  
     if(tnames[tdepth] == NULL) tnames[tdepth] = memalign(8, sizeof(char)*MAXLEN); 
     strcopy(tnames[tdepth],name); 
     FU_DEBUG("Entering \n");}
    What is actually going wrong here? How do I fix this in my program? It is a really large piece of software with many many macros and such. Is there a compiler "switch" that can correct this problem?

  2. #2
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,334
    > Someone suggested it may be an endian problem.
    Nothing you've posted so far suggests that.

    > I turned on warnings and it seems like every one of my macro definitions has a problem.
    Nice - and the warnings were what?
    Insufficient cheese on mouse trap perhaps?

    > What is actually going wrong here?
    Who knows - maybe your tdepth is out of control and off in the weeds somewhere.
    what about tnames - is that allocated with sufficient space?

    > How do I fix this in my program?
    Well you could start with
    #define DEBUG_ENTER(name)
    so that the whole trickery goes away.

    The short answer is compile it with debug, then use a debugger to trap the segfault.
    Then go looking at what has the bad address, then figure out why it's bad.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  3. #3
    Registered User
    Join Date
    Nov 2009
    Posts
    24
    I think I figured it out. I thought memalign was something standard (it's in stdlib) but it is only for the IRIX platform. It is made to allocated the space with a certain alignment. I am going to try to switch them to plain alloc statements and see what happens. memalign is not supported in icc..but for some reason doesnt throw an error?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 10:22 AM
  2. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  3. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  4. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  5. Odd Pointer Problem
    By loopshot in forum C Programming
    Replies: 4
    Last Post: 10-26-2006, 08:49 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21