Background: The code accumulated more, everyone may have tried to write a library, convenient to call, my initial approach is to put the usual functions into one. c file inside, to use when you put a. C added to the group inside, this method is very troublesome, each new project will add half a day.
Objective: To write some functions into the form of a library file, to the form of a header file function interface, so that other projects can be called directly.
1, the new 1 Keil project, wherein the. c file reads as follows:
#include "Hellowork.h"
U8 Hellowork (U8 A, U8 b)
{
return (A+B);
}
2. Set up 1. h files at the same time, the contents are as follows:
#ifndef _hellowork_h_
#define_HELLOWORK_H_
typedef unsigned char U8;
extern U8 Hellowork (U8 A, U8 b);
#endif
3, the entire project compilation options choose Create Library.
4, directly compile, generate personal library file hellowork.lib.
5. Add the runtime files to the project.
6, at the same time, also need to add the . h header file to the project, or the compilation will be error.
7. At this point, the new project will be able to invoke the function of the run-time library normally.
Keil Join the Personal library