"Arnd Hanses" <[EMAIL PROTECTED]> writes:
| On 14 Oct 1999 15:56:04 +0200, Jean-Marc Lasgouttes wrote:
|
| If I don't mix C into too much, maybe this is a bit helpful:
|
| >- static functions: I cannot declare them extern "C" too.
|
| In the context of functions, 'extern' is the mutually exclusive
| opposite of 'static', when the fn is internal to the module.
Does this hold on linkage specifications?
| But I think you can/should/must always write and use a 'global' or
| 'static' or 'static inline' C++ wrapper fn (with better readable ADT
| declaration, if you want) for an 'extern "C" {int foo(int)}' fn:
|
| typedef ADTfoo int;
| extern "C" { int foo(int x) }
|
| static inline ADTfoo
| wrap_foo(ADTfoo x)
| {
| return ( foo(x) )
| }
This example does not solve the problem, and this solution should
never be needed.
| But why not use a 'static inline' C++ wrapper fn which disappears after
| optimizing. But then the compiler uses only the wrapper.
It is often this wrapper that cannot have C++ linkage...the problem
arises when passing pointer to functioncs that have "C" linkage.
The problem is more like:
extern "C" {
int foo(int(*)(int));
}
int bar(int);
You are now not allowed to pass bar to foo because of different
linkage, so:
extern "C" {
int bar_wrapper(int i) {
return bar(i);
}
}
Would solve the problem (I hope)
Lgb