Welcome! Log In Create A New Profile

Advanced

C++ Call from C

Posted by pokeglobe 
C++ Call from C
October 20, 2009 08:30PM
I don't know if the title is proper or not but I know for a fact this works with C
I am trying to call a (Function?) from a C file from C++.

But I get this when it says linking file.elf
undefined reference to `function()'

I put the correct headers. It compiled fine.


In C I have
u32 function()
{
Code here
}
In C++ I called it with
function();

How can I make it link correctly?
Re: C++ Call from C
October 20, 2009 08:39PM
In c, in your header file try:
#ifdef __cplusplus
   extern "C" {
#endif /* __cplusplus */

u32 function();

#ifdef __cplusplus
   }
#endif /* __cplusplus */
Re: C++ Call from C
October 20, 2009 08:49PM
If you mean the file with the s32 function() header file. Like Functionfile.h I just did. It removed all of the warnings but didn't link still. Same error.
Re: C++ Call from C
October 20, 2009 08:58PM
Could you paste your Functionfile.h.
Re: C++ Call from C
October 20, 2009 08:59PM
My bad I accidently forgot to rename u32 function() to my function name.
Sorry and thanks a lot :)
Sorry, only registered users may post in this forum.

Click here to login