c and c++ linkage with libraries -


Suppose I have a C ++ Library libror that uses classes and templates. Suppose I have a custom C ++ header with myLink.h with the following:

  #include "lib.h" // call methods that use templates and sections from lib.h // and the return function is an integer integer based on the information received from the called operation. Extern "c" int foo (int param1, const int param2);   

Now assume that I test.c. I am in a file named Is this function legal to call fu ()?

  // test.c int first = foo (5, 6);   

In addition, what is happening in the compilation object code / linker phase?

Thank you!

Is this function legal to call fu ()?

  int first = foo (5, 6);   

Yes, it is legal though you should read below to make sure that it will link the legal call.

Is the compilation running on the object code / linker step?

The use of classes will not interfere C ++ Classes Object codes will be compiled, which will be understood by Linker.

Edit with Chris Dodd's comment:

Your templates will also be created based on this foo call them.

Comments