| View previous topic :: View next topic | 
	
	
		| Author | Message | 
	
		| mabedin000 
 
 
 Joined: 23 Aug 2023
 Posts: 15
 
 
 
			    
 
 | 
			
				| Function definition differernt from previous definition |  
				|  Posted: Thu Aug 24, 2023 7:49 am |   |  
				| 
 |  
				| 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: 9589
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Aug 24, 2023 8:15 am |   |  
				| 
 |  
				| It may be that you're trying to create a 2nd function, with the same name ?? |  | 
	
		|  | 
	
		| mabedin000 
 
 
 Joined: 23 Aug 2023
 Posts: 15
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Aug 24, 2023 8:42 am |   |  
				| 
 |  
				| 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: 9589
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Aug 24, 2023 11:01 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Aug 24, 2023 11:32 am |   |  
				| 
 |  
				| 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: 350
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Aug 24, 2023 3:12 pm |   |  
				| 
 |  
				| One has (void) and the other has () so they are different |  | 
	
		|  | 
	
		| temtronic 
 
 
 Joined: 01 Jul 2010
 Posts: 9589
 Location: Greensville,Ontario
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Thu Aug 24, 2023 3:26 pm |   |  
				| 
 |  
				| 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: 19967
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Aug 25, 2023 3:03 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Aug 25, 2023 7:08 am |   |  
				| 
 |  
				| 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: 19967
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Aug 25, 2023 7:13 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Aug 25, 2023 7:32 am |   |  
				| 
 |  
				| 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: 19967
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Aug 25, 2023 7:39 am |   |  
				| 
 |  
				| 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
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Aug 25, 2023 7:47 am |   |  
				| 
 |  
				| 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: 19967
 
 
 
			    
 
 | 
			
				|  |  
				|  Posted: Fri Aug 25, 2023 9:06 am |   |  
				| 
 |  
				| 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.
 |  | 
	
		|  | 
	
		|  |