![](templates/subSilver/images/CCSLogo.jpg) |
![CCS C Software and Maintenance Offers](templates/subSilver/images/forumAd6.jpg) |
View previous topic :: View next topic |
Author |
Message |
Herbert
Joined: 20 Jul 2008 Posts: 32 Location: Brisbane, Australia
|
Compiler generates duplicate functions during compilation |
Posted: Sun Dec 07, 2008 5:53 am |
|
|
I have a program that has been steadily growing in size and a lot of code is added throught "includes". All this has been working fine. While I think of it I am using compiler PCWH 4.079 on XP.
I have just added in some more code by another "include". Curiously, now I get a compilation error that says "Identifier is already used in this scope" on the function name of the very first function in the new included file. And no it is not already used. Even if I change the name to something totally unique(say add some characters to the function name), I get the same result.
Interestingly, if I mouse over the function name in the source code, I see listed two versions of the function, both with the same function name. Where the problem seems to arise, is one of the two functions has a very different series of arguments in the definition it shows. One of the definitions matches how I have defined it(with no arguments) and one can have many different arguments in it. The arguments do seem to have come from within my code somewhere, but not sure where at this stage.
This behaviour is reversible, that is the problem goes away when I un"include" the new file in the main program.
To test if it is something unique in my first function I have added a new totally inane first function and the problem repeats. Also have noticed that reducing the number of "defines" at the start of this included file can remove the problem. But it s not seem to be associated with any particular define, it seems to be more the number of defines. Not sure if it helps any, but here are the first few lines of the newly included file, with some comments removed -
Code: |
#define APIRx_Idle 0 //No API Rx frame reception under way
#define APIRx_Start_Found 1 //Start delimiter has been found
#define APIRx_Length_MSB_Rxed 2 //MSB of message length has been received
#define APIRx_Rxing_Frame 3 //LSB of message length has been received and receiving rest of API frame
#define APIRx_Frame_Finished 4 //Frame reception is completed
/******************************************************************************/
void test_function()
{
}
/******************************************************************************/
void Handle_Start_API_Frame_A()
|
The test_function is the newly added in function and the second function is the one I first found the problem on.
I also find that if the compiler comes up with two different versions of the function and the function arguments match i.e. same number of arguments and same type for each argument i.e. one can have an int8 argument and one can have a char argument, then the compiler is happy. How do I change the arguments that the compiler comes up with? By commenting out different defines at the start of the new include file.
Still trying different variations, to try to narrow the issue down. If anybody has any interesting insights into this problem, please let me know. Thanx. |
|
![](templates/subSilver/images/spacer.gif) |
Herbert
Joined: 20 Jul 2008 Posts: 32 Location: Brisbane, Australia
|
|
Posted: Sun Dec 07, 2008 6:33 am |
|
|
Have gotten a little further. Seem to have removed the duplicate, but different arguments, definitions seen by mouse over. Seemed to be triggered by the inclusion of a header file in another include file, the header file defining the form of one of the functions in that other include file. Removed the need for the header file by moving the function forward in that file, so that it is defined before it is used.
But this still leaves me with the "Identifier is already used in this scope" message. Seems to be caused by some totally different issue. Happens at the "test_function", which I have just inserted for testing.
A point of note is that the actual line identified by the compiler is the one after "void test_function_XXX()" and only contains a curly opening brace. And yes I have changed the function name, yet again, just in case I lucked out with my earlier function name choice. |
|
![](templates/subSilver/images/spacer.gif) |
Herbert
Joined: 20 Jul 2008 Posts: 32 Location: Brisbane, Australia
|
|
Posted: Sun Dec 07, 2008 11:42 am |
|
|
Found it. In my block of "include" statements I had managed to include the one file twice and not noticed it. Silly person! |
|
![](templates/subSilver/images/spacer.gif) |
|
|
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
|