Nios® II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
Announcements
Intel Support hours are Monday-Fridays, 8am-5pm PST, except Holidays. Thanks to our community members who provide support during our down time or before we get to your questions. We appreciate you!

Need Forum Guidance? Click here
Search our FPGA Knowledge Articles here.
12455 Discussions

How use altera_avalon_fifi_xxx with a .cpp file ?

Altera_Forum
Honored Contributor II
820 Views

Hi, 

I try to use altera_avalon_fifo_init() function in .cpp file extension. 

The compilation is OK but the linker does't find the function defined in bsp (in library libhal_bsp.a). The error is : 

c:\dev\e111\fpga\fit\software\test06/other1.cpp:9: undefined reference to `altera_avalon_fifo_init(unsigned long, unsigned long, unsigned long, unsigned long)' 

 

But, when I rename the file with .c extension, all is ok. 

Is it possible to use altera_avalon_fifo_init() (or any functions in BSP) into .cpp file ? 

 

I use Eclipse Indigo. My project is created with "Nios II Application and BSP from Template" 

 

Best regards 

Eric
0 Kudos
2 Replies
Altera_Forum
Honored Contributor II
134 Views

I remember that if you define a function (i.e. testcpp() ) in a cpp file, you must declare it with the extern "C" directive in order to call it from a .c files. 

 

extern "C" int testcpp (int n); 

int testcpp (int n) 

/* function body */ 

 

I think you must use something similar for calling .c functions from .cpp source files.
Altera_Forum
Honored Contributor II
134 Views

Hi Cris72, 

Thanks a lot. Now all is OK. 

Best regards 

Eric
Reply