UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

AR# 19240

11.1 EDK - How can I use functions compiled with LibGen in my C++ application?

Description

How can I use functions compiled with LibGen in my C++ application?

Solution

Depending on whether the C++ compiler or the C compiler is chosen to compile a source file, the corresponding symbol naming conventions are used. Consequently, if you try to mix and match C and C++ code and use different compilers for both, you will likely run into undefined references, when the references actually exist. In general, the C++ compiler compiles symbols for C++ linkage and the C compiler for C linkage. If you want to mix C++ and C code, you must ensure that your C++ compiler is alerted to the external C linkage by using the extern "C" { } construct. You must wrap the declarations of external C objects within this construct. For standard EDK-provided external references that have declarations in EDK header files, use something similar to the following:

extern "C" {

#include "xparameters.h"

#include "gpio.h"

}

This forces the compiler to create all references to the entities described within "xparameters.h" and "gpio.h" as C linkage.

AR# 19240
Date Created 09/03/2007
Last Updated 12/15/2012
Status Active
Type General Article