Strange function declaration in header file.

I'm looking at a header file like below, and it has a class called foo and down at the bottom is a function declaration called boo, and it has the class foo in front of the function declaration, and it's wrapped around extern "C". Why did they do this? I've never seen a class in front of a function declaration. Was this for compiling or linking.

/*header file*/
class foo who
extern "C"

foo short boo ( ) ;

#ifdef __cplusplus

Last edited on
You didn't paste all of the code.

This is for linking. In C++, the complexities of overloading functions and being within namespaces and classes and such means that the exported names of functions look 'mangled', it's called name mangling. To be compatible with C, you can mark a function extern "C" and it will be exported without the mangled name, but this means you can run into name collisions.
Topic archived. No new replies allowed.