Header file path settings in keil4

Source: Internet
Author: User

Header file path settings in keil4

It has been plagued by the path setting of the header file for a long time. Now I know it!

How to set the path of the header file in keil4:

Suppose there are several files:

Main. c Dong. c Peng. h

Both main. C and Dong. c depend on Peng. h. Their contents are as follows:

Main. C:


Absolute path: e: \ my_documents \ Keil \ C51 \ include \ FF \ dd \ UU

Dong. h:


Absolute path: e: \ my_documents \ Keil \ C51 \ include \ KK \ Ki \ ts \ dfbh

Peng. h:


Absolute path: e: \ my_documents \ Keil \ C51 \ include \ dd \ JJ \ PP \ kk

 

Here we will explain:

In Windows, ". \" indicates the current directory, ".. \" indicates the upper-level directory of the current directory, and
".. \" Can be used together, that is, it can be written as ".. \... \" to indicate the upper-level directory of the current directory.

In Linux, "./" indicates the current directory, "./" indicates the upper-level directory of the current directory, and
"../" Can be used together, that is, it can be written as "../" to indicate the upper-level directory of the current directory

Here I put them under different folders, because the source files suffixed with. C will participate in compilation as long as they are added to the project, and must be added to the project. So here we will only summarize how to add several header file directories.

 

 

Method 1 add in the development environment of Keil:

 

 

1.

2.

 

 

 

 

 

 

 

 

 

 

3.

4.

 

 

 

 

 

 

 

 

 

 

5.

6.

 

 

 

 

 

 

 

 

 

 

7.

Note that the header file directory generated by the above system is:. \ dd \ JJ \ PP \ KK, where. \ is relative to the project file. Uvproj. \ Indicates the current directory of the project file. The absolute path of the project file is:E: \ my_documents \ Keil \ C51 \ include, The absolute path of Peng. H is:E: \ my_documents \ Keil \ C51 \ include \ dd \ JJ \ PP \ KK,It is easy to see that the Peng. h file is inE: \ my_documents \ Keil \ C51 \ include \ dd \ JJ \ PP \ kkDirectory.

 

Assume that the project file is inE: \ Microcontroller series \ embedded \ UCOS \ uCOS-II version \ ucosii2.91 \ MDK-ARMAnd one of the header files is in:E: \ Microcontroller series \ embedded \ UCOS \ uCOS-II \ ucosii2.91 \ User \ uCOS-II \ Source

In the Keil environment, set the header file directory :..\User \ uCOS-II \ source.

 

 

Method 2 absolute path

Write the absolute path of the header file to # include. As follows:

In Main. C:

In dong. C:

 

 

Method 3: Relative Path Method

The absolute path of Peng. H is: e: \ my_documents \ Keil \ C51 \ include \ dd \ JJ \ PP \ kk

The absolute path of Main. C is: e: \ my_documents \ Keil \ C51 \ include \ FF \ dd \ UU

The absolute path of Dong. C is: e: \ my_documents \ Keil \ C51 \ include \ KK \ Ki \ ts \ dfbh.

 

Through analysis, we can see that the Peng. h path relative to main. C is:

... \ Dd \ JJ \ PP \ kk

The Peng. h path relative to Dong. C is:

... \ Dd \ JJ \ PP \ kk

Therefore, modify main. C as follows:

In dong. C, modify the following:

Method 4: relative directory + relative directory

In some. c files, the header file has the following representation:

If OS _dbg.c exists, the header file is written as follows:

# Include "uCOS-II \ source \ ucos_ii.h"

The absolute path of OS _dbg.c is: E: \ Microcontroller series \ embedded \ UCOS \ uCOS-II version \ ucosii2.91 \ User \ uCOS-II \ ports \ ARM-Cortex-M3 \ realview

The absolute path of ucos_ii.h is:E: \ Microcontroller series \ embedded \ UCOS \ uCOS-II \ ucosii2.91 \ User \ uCOS-II \ Source

In the Keil environment, the header file path settings include:

Current. UvprojThe absolute path of is:E: \ Microcontroller series \ embedded \ UCOS \ uCOS-II version \ ucosii2.91 \ MDK-ARM

As you can see,".. \ User"+"UCOS-II \ source \ ucos_ii.h"NoUcos_ii.hRelative. Uvproj path? That is, ".. \ User \ uCOS-II \ source \ ucos_ii.h ".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.