Thread: help with linker error

  1. #1
    Registered User
    Join Date
    Feb 2002
    Posts
    18

    help with linker error

    I'm trying to debug and received this compiler error message:
    Unable to optimize func1(). Compile stopped. Use the following workaround:
    #pragma OPTIMIZE(4)
    func1(void)
    {
    ...
    } // end func1
    #pragma OPTIMIZE(5)
    ...

    When I add these lines in, I get the following linker error:
    LINKER ERROR: Initialisation of variable must be preceded by the reserved word code : MODULE = CFILE_CONTAINING_FUNC1

    Anyone have a clue what this means?

    wolf

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    What compiler are you using?

  3. #3
    Registered User
    Join Date
    Feb 2002
    Posts
    18
    I'm developing using VC++ 6.0. The code compiles and links fine using it.

    However, it needs to be embedded and the device requires the MS-DOS C51 compiler.
    Last edited by wolf; 08-05-2004 at 12:29 PM.

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    It usually means your function is too complicated to be optimised.
    A large functions with lots of local variables, lots of nested control structures etc will take a lot more memory to analyse than a small function. The compiler is basically telling you your function is too complicated.

    Try simplifying the code, like moving blocks of code out into other functions, each of which would then be optimised in their own right.
    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
    Registered User
    Join Date
    Feb 2002
    Posts
    18
    Thanks. I found the function was only called in one place, and copied all the code in place of the function call. It works now.

  6. #6
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002
    Posts
    192

    Why are you using DOS based Cross Compiler from Windows.

    Quote Originally Posted by wolf
    I'm developing using VC++ 6.0. The code compiles and links fine using it.

    However, it needs to be embedded and the device requires the MS-DOS C51 compiler.
    MS-DOS C51????? Never heard of it. C51 compilers are used for cross compilation to 8051 variant microcontrollers. But you are using VC++ 6.0, a Windows-based stuff.

    Anyone please correct what Im missing? That really doesnt make sense to me.


    -Harsha.
    Help everyone you can

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Anyone please correct what Im missing?
    You're missing the fact that its a lot easier to test the code on the PC than some embedded device.
    For 95% of the code (if done properly), it really doesn't care where it is run - it will always do the same thing. It means you can get an awful lot of the trivial bugs out of the way before you have to confront the tricky ones which only become apparent on the target.
    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.

  8. #8
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002
    Posts
    192

    You got me wrong Salem ... :-)

    Quote Originally Posted by Salem
    > Anyone please correct what Im missing?
    You're missing the fact that its a lot easier to test the code on the PC than some embedded device.
    For 95% of the code (if done properly), it really doesn't care where it is run - it will always do the same thing. It means you can get an awful lot of the trivial bugs out of the way before you have to confront the tricky ones which only become apparent on the target.
    You got me totally wrong Salem....

    I know what a cross-compiler is and how helpful it is to eliminate many bugs before the code actually gets into an Emb-Sys.

    What I did not understand is the fact that Wolf is using an MS-DOS C51 cross compiler in MS Windows!!!! Why doesnt he use something like uV2 from Keil or something similar (like Raisonnance C51 compiler) thats made for Windows....

    Cheers,
    Harsha.
    Help everyone you can

  9. #9
    Im a Capricorn vsriharsha's Avatar
    Join Date
    Feb 2002
    Posts
    192
    Ok, I also meant the other stuff like Simulators, Debuggers etc. apart from Compilers (lest someone starts pointing...'You cannot Test Code with a Compiler....blah blah blah....'

    On the whole I mean Development Environment.
    Help everyone you can

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Errors including <windows.h>
    By jw232 in forum Windows Programming
    Replies: 4
    Last Post: 07-29-2008, 01:29 PM
  2. Crazy errors caused by class, never seen before..
    By Shamino in forum C++ Programming
    Replies: 2
    Last Post: 06-10-2007, 11:54 AM
  3. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  4. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 04:49 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 05:27 AM