Embedded systems header functions
I am new to embedded systems and want to learn more,
I am currently optimizing a software with regards on the footprint for an ARM embedded system, and are wondering, the header files that you include in your source files. Where are they put?
Right now I am just using a software (OVP) to simulate the ARM hardware platform but in real hardware, you have to put the header files somewhere right? Like in gcc have the standard library on the hd. Do we have to insert this library in the embedded machine as well? Space is limited! And is there any way to minimize the size of the library? Thanks!
Example
#include <stdio.h>
#include <stdlib.h>
I am using the cross compiler arm-elf-gcc
Best Regards
Mr Gigu
You appear to possess a few fundamental misunderstandings about compiled executable code. The following applies to embedded and desktop systems.
Header files are no more than sourcefiles like any other. The difference is that they are inserted into the compilation unit by the pre-processor rather than compiled directly. Also in most cases they contain declarative statements only, and do not generally contribute to the generated code in the sense of executable instructions or stored data.
At runtime none of your source code is required to exist on the target; it is the work of the compiler to generate native executable machine code from your source. It is this machine code that is stored and runs on the target.
A header file is not the same thing as a library. It is merely (generally) the declaration of library content (function prototypes and other symbol declarations such as constants, data, macros, enumerations). The library takes the form of pre-compiled/assembled object code stored in a combined archive. It is the job of the linker to combine the required library code with the object code generated from compilation of your own source. It is this linked executable that is stored and executed on the target, not the original source code.
An exception regarding header files containing declarative code only is when they contain in-line code or executable code in a macro. However such code only occupies space in your application if explicitly called by the application.
When library code is linked, only those library object code components required to resolve references in the application code are linked, not the entire library (unless the entire library is composed of only a single object file).
The library does indeed have to get included in the image that is burned into the embedded system's memory. Usually you tell the linker to strip out unused functions, which goes a long way towards conserving memory. But this memory is the memory your program takes up in flash or whatever you use for non-volatile code storage. It doesn't say anything about how much RAM your program takes at runtime. You can also tell your compiler to optimize for space, and also use different runtime libraries - the ones provided by the vendor are often not as fast or small as they could be.
链接地址: http://www.djcxy.com/p/86920.html上一篇: 我可以混合手臂吗?
下一篇: 嵌入式系统头部功能