Ecos system does not correctly link to the problem of the Cyg_user_start function defined in the C + + source file and the method of resolution

Source: Internet
Author: User

Before you define the Cyg_user_start function in a C + + source file, declare it as a C function. can solve this problem.

Ecos official website: http://ecos.sourceware.org
Ecos Chinese Technology Network: http://www.52ecos.net
Ecos Exchange QQ Group: 144940146.


http://blog.csdn.net/zoomdy/article/details/39396085
Mingdu.zheng<at>gmail<dot>com


Problem: Define Cyg_user_start in C + + source files. The Ecos application, which is finally compiled according to expectations, enters the function after the system is initialized, and the actual execution result is not. By debugging the discovery always goes into the default Cyg_user_start function of the ecos system located in Infra/<versin>/src/userstart.cxx.



Workaround: Before defining the Cyg_user_start function, declare it as a C function.


#include <CYG/INFRA/CYG_TYPE.H>EXTERNC void Cyg_user_start (void); Declared as C function void Cyg_user_start (void) {...}

Explanation: C + + requires support for function overloading. Therefore, the C + + compiler will name the function name conversion, in C + + cyg_user_start (void) of the last symbol named _Z14CYG_USER_STARTV, and the linker is only to recognize the symbolic name, for the connector _z14cyg_user_ StarTV and Cyg_user_start are two different functions, so they cannot be linked correctly to their own defined Cyg_user_start functions, using EXTERNC (the macros defined in Cyg_type.h, which is expanded to extern "C" in C + +) Cyg_ The User_start function is declared as a C function. The C + + compiler does not name-convert functions declared as C functions, and the last symbolic name of void Cyg_user_start (void) is still cyg_user_start.

Use NM to view the generated. o file to view the symbol table. You can find this problem by looking at the symbol table.

Ecos system does not correctly link to the problem of the Cyg_user_start function defined in the C + + source file and the method of resolution

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.