|
|
View previous topic :: View next topic |
Author |
Message |
Dave the Coding Monkey
Joined: 10 Nov 2006 Posts: 2
|
getting errors from manually locating function in ROM |
Posted: Fri Nov 10, 2006 11:08 pm |
|
|
Hi all,
I am currently using compiler v4.005, and I am having trouble figuring out a compiler error arising from trying to manually locate functions in my code.
The basic structure of my code looks something like this:
Code: |
#include "header.h"
//forward declarations of functions:
void function1(void);
void function2(void);
void main(void)
{
//some code
function1();
function2();
}
void function1(void)
{
//code and stuff
}
void function2(void)
{
//more code and stuff
}
|
So that's all pretty basic, and worked just fine. For various reasons (that don't really pertain to the situation), I decided I needed to pin down the ROM locations of some of my functions. I did this my adding some #ORG directives:
Code: |
#include "header.h"
//forward declarations of functions:
void function1(void);
void function2(void);
void main(void)
{
//some code
function1();
function2();
}
#ORG F1_BASE_ADDR, F1_BASE_ADDR + F1_SIZE
void function1(void)
{
//code and stuff
}
#ORG F2_BASE_ADDR, F2_BASE_ADDR + F2_SIZE
void function2(void)
{
//more code and stuff
}
|
Once I have done that, however, I start getting "No overload function matches" errors for any calls made to the functions from main(). (I have made sure that the reserved ROM locations are adequately sized, and do not overlap other reserved areas.)
To be honest, I do not really understand what that error message means. It sounds to me like the compiler is complaining that the functions are now somehow out of the main routine's calling scope (even though they've already been declared at the top of the code).
Does anyone have any insight to give me on this error? I hope so, because this situation has confused me terribly...
Thanks,
Dave |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sat Nov 11, 2006 12:20 am |
|
|
I can find only one instance of that error message in Google.
That's pretty rare.
My advice is to download a different version of the compiler, if you can,
and try it. Vs. 4.005 is a very early version of vs. 4.
Or, download vs. 3.249. |
|
|
Mark
Joined: 07 Sep 2003 Posts: 2838 Location: Atlanta, GA
|
|
Posted: Sat Nov 11, 2006 8:32 am |
|
|
Try declaring them like this
Code: |
#include "header.h"
#ORG F1_BASE_ADDR, F1_BASE_ADDR + F1_SIZE
void function1(void)
{
//code and stuff
}
#ORG F2_BASE_ADDR, F2_BASE_ADDR + F2_SIZE
void function2(void)
{
//more code and stuff
}
void main(void)
{
//some code
function1();
function2();
}
|
|
|
|
Dave the Coding Monkey
Joined: 10 Nov 2006 Posts: 2
|
|
Posted: Sat Nov 11, 2006 7:54 pm |
|
|
Well, I went through my code and moved all child functions to appear in the code file before their parent functions (i.e. I removed all need for forward-declaring the functions), and now it compiles just fine. I basically had to invert my entire c-file, as I always write my code so that parents appear first (I think it makes it easier to read that way). I've been cutting and pasting for the last hour . I still don't understand why it makes a difference to the compiler, but important thing is that I have the code working again the way I want it to.
Thanks all,
Dave |
|
|
Ttelmah Guest
|
|
Posted: Mon Nov 13, 2006 3:45 am |
|
|
The key is what is included in the function prototype. If (for example), you declare a function as 'separate', this affects how the compiler generates the calls to the function, and has to be included in the prototype. Now, when you force an 'org' for a function, you also force it to be separate. This is implicit in the org declaration, but not stated. Your prototype version, should work, if you declare the prototypes as:
Code: |
//forward declarations of functions:
#separate
void function1(void);
#separate
void function2(void);
|
The error, means that the prototype function it has found, does not 'match' the real function of the same name, so it has gone looking for other versions (since the compiler now partially supports function overloading), and has failed to find any that exactly match.
Best Wishes |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|