CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Function definition differernt from previous definition

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
mabedin000



Joined: 23 Aug 2023
Posts: 15

View user's profile Send private message

Function definition differernt from previous definition
PostPosted: Thu Aug 24, 2023 7:49 am     Reply with quote

I had memory ROM storage issue while compiling and then I used #separate function to store code into new segment of memory. Now I have a new problem which I do not know what to do. I am not a professional coder but I just know how things work. certainly these type of in depth problems are out of my hand.


error 29 ..... Line 1105(0,1): Function definition different from previous definition ClearDecimalDisplay Param#1

Not sure if I used the #separate function correctly.

Any help or suggestion will be appreciated. Thank you in advance
temtronic



Joined: 01 Jul 2010
Posts: 9118
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 24, 2023 8:15 am     Reply with quote

It may be that you're trying to create a 2nd function, with the same name ??
mabedin000



Joined: 23 Aug 2023
Posts: 15

View user's profile Send private message

PostPosted: Thu Aug 24, 2023 8:42 am     Reply with quote

I dont thing so, I just added #separate syntax before the prototype and after

#separate
void ClearDecimalDisplay(void)

#separate (This line has the Function Definition error)
void ClearDecimalDisplay(void)

{
.....
{
.....
}
.....
}
temtronic



Joined: 01 Jul 2010
Posts: 9118
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 24, 2023 11:01 am     Reply with quote

What you show are TWO identically named functions, one after the other.....

If this isn't what you coded, cut and paste your actual code a few lines before and after where the error occours
mabedin000



Joined: 23 Aug 2023
Posts: 15

View user's profile Send private message

PostPosted: Thu Aug 24, 2023 11:32 am     Reply with quote

Error 71...OUT of ROM, A segment or the program is too large ClearDecimalDisplay Param#1


Seg 00096-03FFE, 0034 left, need 00060
Seg 00000-00002, 0000 left, need 00060
Seg 00004-00006, 0004 left, need 00060
Seg 00008-00094, 0000 left, need 00060

1 Error, 0 warnings


So the ROM is full and I added #separate function to divide the prototype so that it can fit in.

#separate (I added)
void ClearDecimalDisplay(void)
#separate ( I added)
void ClearDecimalDisplay() ( I added)
{
char c,dispbufr;


dispbufr = 0x25;


//-----------------------------------
// Blank Most Sig Char
//-----------------------------------
_DISPSEL = 0;
SSP1BUF = dispbufr--;
while(_BF == 0);

SSP1BUF = 0x20;


while(_BF == 0);
_DISPSEL = 1;


//-----------------------------------
// 000.0
//-----------------------------------
for (c = 0; c < 5; c++)
{
_DISPSEL = 0;
SSP1BUF = dispbufr--;
while(_BF == 0);


if (c == 3)
SSP1BUF = 0xA0;
else
SSP1BUF = 0x30;

while(_BF == 0);
_DISPSEL = 1;
}

numberposition = 0;

displaynumber[0] = 0x30;
displaynumber[1] = 0xA0;
displaynumber[2] = 0x30;
displaynumber[3] = 0x30;
displaynumber[4] = 0x30;

}


Now I have "Function definition different from previous definition" error.
1 Error, 0 warnings
Build Failed.
gaugeguy



Joined: 05 Apr 2011
Posts: 290

View user's profile Send private message

PostPosted: Thu Aug 24, 2023 3:12 pm     Reply with quote

One has (void) and the other has () so they are different
temtronic



Joined: 01 Jul 2010
Posts: 9118
Location: Greensville,Ontario

View user's profile Send private message

PostPosted: Thu Aug 24, 2023 3:26 pm     Reply with quote

Maybe the compiler sees the NAMES of the functions first as 'duplicates' before seeing the 'attributes' of them (void) or (passing parameters) ??

The huge problem is he's run out of codespace, needs a bigger PIC OR recode what he has.
Ttelmah



Joined: 11 Mar 2010
Posts: 19232

View user's profile Send private message

PostPosted: Fri Aug 25, 2023 3:03 am     Reply with quote

Lets step through several parts of this:

First, the fundamental problem is he has run out of space in his chip.
The 'point' about using #separate, is where instead of actually running
out of space a user has run out of space in a single page of the ROM,
so by splitting the code up, you can make it fit in the rest of the ROM.
This is not the case here. Jay has pointed this out.

Function prototypes must match the real function. So if the function
is #separate, the prototype must also be declared as #separate. Also
all types must be the same in the prototype as the actual function. The
prototype here does not match the function, here the new error.
Gaugeguy has pointed this out.
However using #separate won't solve his problem, since he has fundamentally run out of space. Jay has also pointed this out.

It is possible that he may be able to make the code fit by carrying out
some optimisation. Look and see if any parts are duplicated, that could
instead be turned into functions. It is often possible to save space at
a slight cost in speed this way.

More careful programming, or a larger chip are needed.
mabedin000



Joined: 23 Aug 2023
Posts: 15

View user's profile Send private message

PostPosted: Fri Aug 25, 2023 7:08 am     Reply with quote

One has (void) and the other has () so they are different

I have the same "Function definition different from previous definition" issue even if I dont pass the parameters.

#separate
void ClearDecimalDisplay(void)
#separate
void ClearDecimalDisplay(void)
Ttelmah



Joined: 11 Mar 2010
Posts: 19232

View user's profile Send private message

PostPosted: Fri Aug 25, 2023 7:13 am     Reply with quote

They are still not the same:
Code:

#separate
void ClearDecimalDisplay(void) ;
//Note the semicolon. - Makes this a complete declaration


#separate
void ClearDecimalDisplay(void)
{
// code here - makes this the actual function
}



The actual declaration is followed by code. The prototype needs to have
a semi-colon to represent some code.
mabedin000



Joined: 23 Aug 2023
Posts: 15

View user's profile Send private message

PostPosted: Fri Aug 25, 2023 7:32 am     Reply with quote

After adding semicolon.

Error tab opened: Cannot open file "C:/Users/................ The process cannot acces the file because it is being used by another proces.

at the line- where semicolon being used.

Invalid overload function

and bunch of other declaration error follows up
Ttelmah



Joined: 11 Mar 2010
Posts: 19232

View user's profile Send private message

PostPosted: Fri Aug 25, 2023 7:39 am     Reply with quote

This means you have something else declared called
ClearDecimalDisplay with different variables involved. Hence an 'overload'.

You have another declaration for this somewhere that is different.
mabedin000



Joined: 23 Aug 2023
Posts: 15

View user's profile Send private message

PostPosted: Fri Aug 25, 2023 7:47 am     Reply with quote

Yes I have this ClearDecimalDisplay(); line under another prototype to link them together.

How to make a difference between these two decertations and make it work? I am not a professional programmer, I may ask some non-sense questions.
Ttelmah



Joined: 11 Mar 2010
Posts: 19232

View user's profile Send private message

PostPosted: Fri Aug 25, 2023 9:06 am     Reply with quote

You should only ever have one prototype. No point in having two. You talk
about 'link them together'. If you are using linking. Don't.
CCS at heart is a single pass compiler. Linking things will actually make the
resulting code larger than it would be if you simply have it all compiled
together, and might be the reason you are running out of ROM.

Just have one main file, with the prototype headers loaded near it's start.
Don't try to link, just compile as a single entity.
If you are using MPLAB, then just have the single main file as the only
entry in the project.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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