Thread: Compiler problem ?!

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    4

    Compiler problem ?!

    Hello,

    today while working on ColdFire microchip with Freescale Codewarrior 6.4 I encountered a problem.
    Lets say one function is composed of other functions, and when I compile the code it seems like
    that this other functions aren't included in the output file.

    This functions are used for separating bytes from an short or a long in and to merge 2 bytes into a short and 4 bytes into a long int. The sample code could be seen below:

    Code:
    UINT16 convert_two_bytes_to_UINT16(UINT8 *bytes)
    {    UINT16 result = bytes[0];
        result <<= 8;
        result |= bytes[1];
        return result;
    }
    When I use this function in the main function, in the neverending loop the function works and the return value corresponds to the value of 2 bytes.

    I don't know what do to, so if somebody had simmilar problems I cindly ask them for some help.
    Thanks and best regards,
    BoSCHoW.

  2. #2
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    You're getting the right results?

    What's the problem?

  3. #3
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    it seems like
    that this other functions aren't included in the output file.
    And why is it seems so?
    may be it is just inlined...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    I agree with vart, maybe the optimiser has done some pruning and merging of the output file.
    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.

  5. #5
    Officially An Architect brewbuck's Avatar
    Join Date
    Mar 2007
    Location
    Portland, OR
    Posts
    7,396
    Quote Originally Posted by Salem View Post
    I agree with vart, maybe the optimiser has done some pruning and merging of the output file.
    The function should still exist in the object file (since some other module might refer to it) but it may not exist at all in the executable.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dev-C++ compiler problem
    By GrasshopperEsq in forum C++ Programming
    Replies: 19
    Last Post: 05-08-2008, 02:35 AM
  2. Compiler Problem
    By sitestem in forum C++ Programming
    Replies: 2
    Last Post: 04-11-2004, 03:48 PM
  3. Replies: 5
    Last Post: 12-03-2003, 05:47 PM
  4. Problem with compiler
    By knight543 in forum C++ Programming
    Replies: 4
    Last Post: 02-09-2002, 09:16 PM
  5. Please help me with this compiler problem
    By incognito in forum C++ Programming
    Replies: 1
    Last Post: 01-05-2002, 05:14 PM