Thursday, 22 March 2018

Is extern "C" on a c++ function allowed?








I am asking this because I'm writing a C++ program which uses a C library. This library has foreach functions that take a callback (naturally). Obviously, the library would call my callbacks as C functions.



First of all, does this have anything to do with linkage of C vs C++?



If it does, is something like this valid and correct?



extern "C" static bool callback(/*parameters*/)
{

cout << "C++ thing inside the function" << endl;
/* etc */
}

No comments:

Post a Comment

casting - Why wasn&#39;t Tobey Maguire in The Amazing Spider-Man? - Movies &amp; TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...