Jump to content
Sign in to follow this  
joli

Avoid Automatic Removing Unreferenced Functions

Recommended Posts

Is there any option to prevent the compiler remove unreferenced functions?

 

I wondering if any else answer me with yes and how.

 

Right now i have Boostc V6.96 FULL license and next week i will be PRO.

This information may be important because i don't know if this a license limitation.

 

Regards

joli

Share this post


Link to post
Share on other sites

joli,

Is there any option to prevent the compiler remove unreferenced functions?

 

I wondering if any else answer me with yes and how.

 

Right now i have Boostc V6.96 FULL license and next week i will be PRO.

This information may be important because i don't know if this a license limitation.

No. If a function is not reference then local variable cannot be allocated as it is not known where it fits in the call tree. So RAM can't be allocated, and the required bank switching cannot be therefore determined. So the function would be quite incomplete.

 

This is not the case if you declare a function at a fixed address, for then it is assumed to be at the start of stack, so memory will be allocate from that point, even if the function is not called:

void foo() @ 0x100
{
....
}

Regards

Dave

Share this post


Link to post
Share on other sites
joli,
Is there any option to prevent the compiler remove unreferenced functions?

 

I wondering if any else answer me with yes and how.

 

Right now i have Boostc V6.96 FULL license and next week i will be PRO.

This information may be important because i don't know if this a license limitation.

No. If a function is not reference then local variable cannot be allocated as it is not known where it fits in the call tree. So RAM can't be allocated, and the required bank switching cannot be therefore determined. So the function would be quite incomplete.

 

This is not the case if you declare a function at a fixed address, for then it is assumed to be at the start of stack, so memory will be allocate from that point, even if the function is not called:

void foo() @ 0x100
{
....
}

Regards

Dave

Thanks Dave.

Regards,

Joli

Share this post


Link to post
Share on other sites

A different, more "C-like" approach is to reference the function in some way. The most painless way I can think of besides calling the function is to assign it to a function pointer.

 

#include <system.h>

void removed (void)
{
// This function is optimized out
}

void main()
{
for (;;)
{

}
}

 

#include <system.h>

void removed (void)
{
// This function is no longer optimized out
}

void main()
{
void (*funcptr)(void);
funcptr = removed;

for (;;)
{

}
}

 

This method burns a byte or two of RAM and ROM, but you won't have to worry where your code lands.

Share this post


Link to post
Share on other sites

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...