Ecos system does not correctly link to problems and workarounds for custom Cyg_user_start functions in C + + source files

Source: Internet
Author: User

You can resolve the problem by declaring it as a C function before you define the Cyg_user_start function in a C + + source file.

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: Defining Cyg_user_start in a C + + source file, the final compiled Ecos application is expected to enter the function after the system is initialized, and the actual 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 + + because of the need to support function overloading, so the C + + compiler will name the function name translation, in C + + void Cyg_user_start (void) of the final symbol named _Z14CYG_USER_STARTV, and the linker is only known symbol name, For connectors, _Z14CYG_USER_STARTV and Cyg_user_start are two different functions, so they cannot be linked correctly to custom Cyg_user_start functions, using EXTERNC (macros defined in Cyg_type.h, in C + + Expands to extern "C") declares the Cyg_user_start function as a C function, and the C + + compiler does not name-Convert a function declared as a C function, and the final symbol name of void Cyg_user_start (void) remains cyg_user_start. Use NM to view the generated. o file to view the symbol table, which can be found by viewing the symbol table.

Ecos system does not correctly link to problems and workarounds for custom Cyg_user_start functions in C + + source files

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.