Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c function interface question

Tags:

c++

extern "C" int func(int *, Foo);

This is from a sample code from class. But I don't understand how the interface is working, one with no variable name, the other with no type. How is that going to work?

like image 215
stonebird Avatar asked Feb 16 '26 11:02

stonebird


1 Answers

When declaring functions you don't need to specify a parameter name, just a type. Foo in this case is a type.

extern "C" tells the compiler it should use a C-style symbol, which more or less means it won't be using name mangling (which C++ uses to allow multiple functions share a name, but use different parameter sets or namespaces).

like image 158
falstro Avatar answered Feb 19 '26 05:02

falstro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!