No MSL support

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

No MSL support

1,753 Views
flashtoo
Contributor I
I want to create a project without MSL support. It seem that the complier tries to optimize the following to a funciton called __clear() that is in the MSL even though I have not included it in the project. It gives me an link error that __clear can not be found.  Is there some project setting that cleans this up? I don't have any optimizations turned on.
 
char foo[2] = {0,0};  // FAILS, calls __clear
 
Of course if I don't initialize to 0 it works as __clear is not called.
 
char foo[2] = {1,1};  //OK, does not call __clear
 
 
Labels (1)
0 Kudos
2 Replies

375 Views
CompilerGuru
NXP Employee
NXP Employee
Which compiler are you using?

I'm not sure if there is any option to switch off the use of __clear, I think it would be better to actually provide the runtime routine the compiler is using, even if you are not using all the other parts of MSL.
In the end, it makes sense for the compiler to use runtime routines for many tasks, not just for the zero initialization (but this does depend a lot on the used target of course).
Anyway, for (zero terminated) strings, especially large strings with more than just 2 elements, its a good idea to just explicitly write a zero to first element instead of using the C initializer. ANSI C states that if you init a single field or array element, every field/array element has to be written. Therefore in the following snippet
void f(void) {
char local[1000]="";
char local1[1000];
local1[0]= 0;
}


the initialization of local is rather expensive as 1000 char's have to be written, while the initialization of local1 is cheap, just the given assignment is done.

Daniel
0 Kudos

375 Views
flashtoo
Contributor I
Thanks, good points.  I'm using CodeWarrier (and it's compliter). The actual problem I was having was with a structure, not a string.  I used a string as an example as it also fails and was easier to show the problem.  I am using the RTOS (freeRTOS) that comes with the M52233DEMO eval board and it contains many of the same functions as in the MSL. Due to some very sloppy coding on their part it does not play well with the MSL so rather than fix their code, I just opted not to use any MSL functions.  In the long run, I expect to use the MSL for now, this was a faster fix.  It also allows me to minimize (and control) the code footprint, which is another goal of mine
 
Bill
0 Kudos