Solution: Keil reports invalid redeclaration of type name "s32 ″

Source: Internet
Author: User

Keil 4.00.
The firmware packages on the st official website are compiled correctly using the project in stm32f10x_stdperiph_lib_v3.4.0/project/stm32f10x_stdperiph_template. Two methods for creating a project failed:

1. Copy the routine in the firmware package and the corresponding cmsis and stdperiph_driver to the project, and change the C/C ++ include paths item in target options to ".. /;.. /src/APP ;.. /src/cmsis ;.. /src/lib. The compiling error "D:/Keil/ARM/INC/ST/stm32f10x/stm32f10x_type.h (23): Error: #256: invalid redeclaration of type name "s32" (declared at line 470 of "src/APP/stm32f10x. h.

2. If the file added in the project is a link (instead of a copy) in the firmware package, the file is modified according to the structure in the template and the include paths is modified according to the template, the compilation error "Keil/ARM/INC/ST/stm32f10x/stm32f10x_conf.h (147): Warning: # 47-d: incompatible redefinition of macro "hse_value" (declared at line 511 of "stm32f10x_stdperiph_lib_v3.4.0/libraries/cmsis/cm3/devicesupport/ST/stm32f10x/stm32f10x. h.

In the Keil installation directory, the old lib version is used, and the new version is used in the project. The code structure of the two is different. While compiling the project files, the compiler automatically links the files under the Keil installation directory, causing a conflict. However, the option does not find the link to the Lib in the installation directory of Keil.

Problem principle:

Compare the links of the template project in the firmware package one by one the locations of the libraries required for the source code links in the template project and self-built project. If the template links files in the firmware package, such as system_stm32f10x.h or stm32f10x_config.h, that is, the new version of Lib, and the corresponding file link in the self-built project is located in the Keil installation directory, this indicates that the project settings do not contain the path of the library, so that the compiler will automatically find the old files in the installation directory. Compilation errors are caused by different library code structures. Therefore, you must add the path of the new Lib in the include paths column of the project.

Solution:

For the second step of building a project, it is easy to see through the error message that the compilation process links Conf. h under the Keil installation directory, and the file in the firmware package needs to be used. Therefore, add the conf. h directory of the firmware package to include paths to solve the problem.

For the first step of establishing a project, stm32f10x_type.h is not the header file that needs to be included directly in the project source code and is not easy to find the unset link path. Therefore, you can use the method in the "problem principle" to compare the libraries one by one, modify the link path, and locate the unincluded location to solve the problem.

Note that "../" in the path indicates the upper-level directory of the project file, and "./" indicates the same level directory of the project file. In some forums, we can see that the first path posted by others is "../", which is not mandatory. In addition, the compiler can only search for files in the current directory and does not enter the next-level directory. Therefore, the specified path must be very specific.

When this problem occurred, I searched many forums and asked Daniel about the configuration path, but I did not discuss the specific solution. I had to explore it for a while. This is indeed the reason. If I encounter the same question in the future, it is estimated that the answer will be the same. However, there is still a gap between theory and practice.

 

 

 

Related Article

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.