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 CCS Technical Support

#org usage

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



Joined: 16 Sep 2010
Posts: 5

View user's profile Send private message

#org usage
PostPosted: Thu Sep 16, 2010 8:49 am     Reply with quote

Hi,

I'm making firmware for a PIC16F88 µC which needs to have a I2C bootloader. I want all functions which might get executed prior to finishing the bootloader to be put in address range 0x0E40 - 0x0FFF.

If I do the following:
Code:

-> main.h:
------------------
void bootloader (void);
void init (void);

-> main.c:
------------------
#ORG 0x0E40 0x0FFF // define bootloader segment
void main()
{
   init();
   bootloader();
}

#ORG 0x0E40 // located in bootloader segment
void init (void)
{
   ...
}

#ORG 0x0E40 // located in bootloader segment
void bootloader (void)
{
   ...
}

I get "Error 166 "main.c" Line 150(1,2): Invalid overload function bootloader

If I don't place the function prototypes in main.h, and declare the functions prior to void main (void) then it builds correctly. Also when I don't put the #org statements, it builds correctly, but isn't placed in the correct memory segments.

Why can't it handle function prototypes when using #org statements? Is there a workaround / solution for this?

I'm using PCWH 4.0.69.

Best regards,
Diricx Bart
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Sep 16, 2010 2:51 pm     Reply with quote

I was able to make it compile by putting #separate above each prototype.
Quote:

// main.h

#separate
void bootloader(void);
#separate
void init(void);
Bart Diricx



Joined: 16 Sep 2010
Posts: 5

View user's profile Send private message

PostPosted: Fri Sep 17, 2010 1:03 am     Reply with quote

Thanks, this works indeed !
Ttelmah



Joined: 11 Mar 2010
Posts: 19552

View user's profile Send private message

PostPosted: Sat Sep 18, 2010 8:01 am     Reply with quote

It makes a lot of sense if you think about it.

If you remember that for 'single call' functions, the default is always to put them 'inline', the original prototype for the function, effectively becomes:
Code:

#inline
void bootloader(void);


You then when you come to the 'real' definition, tell the compiler to put this function as a distinct entity, somewhere else, which then clashes with the original definition.

By using #separate, you are telling the compiler to treat this as an entity that is _not_ going to be put inline, which then agrees with the latter definition.

Makes total sense, just a pity it is not documented!.

Best Wishes
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