The correct solution
Since #include is a simple text replacement by the preprocessor, we can put the extern "C" declaration in our C++ code, where it belongs:
//main.cpp
extern "C" {
#include "foo.h"
}
int main() {
foo(22);
}
This way, everything inside the header, including the indirectly included declarations in other C headers, appear inside the extern "C" declaration.
Approach 3: Synbol Tables
Built-in function locals() and globals() return a dictionary of current local and global symbol table respectively. So you could call a function just like:
def my_func(arg1, arg2):
print(arg1, arg2)
return arg1 + arg2
r = locals()['my_func'](http://1, 2)
print(r)
The output is:
1 2
3
This approach is just like the examples provided in the very beginning of this post, in which, I maintained a symbol table by myself and called the function by its string-typed name.
25 rappel de fonctionnalités GIT
Download the fastest DVD copy software from DVDFab. Best DVD decrypter to copy any DVD with any copy protection! It copies the entire DVD movie on the hard disk and removes any kind of protection.
Get Notepad++ Plugins at SourceForge.net. Fast, secure and free downloads from the largest Open Source applications and software directory. Notepad++ plugins is a collection of tools which plays a role of completion for Notepad++. This project contains Explorer, Function List, Hex Editor, Spell Checker and a console program NppExec. Other plugin developers are invited to share their projects