swapnil.palod@[EMAIL PROTECTED]
<swapnil.palod@[EMAIL PROTECTED]
> wrote:
> I was having trouble since long time removing some of the warnings
> from my file which was builted on Solaris 9 using C++ compiler 5.0.3.
>
> Your help would be highly appreciated.
> Warning message is :
>
A slight reformating of the error message makes it a bit more clearer:
Warning (Anachronism): Formal argument destroy_value_func of type
extern "C" void(*)(Void *)
in call to
g_hash_table(
extern "C" unsigned (*)(const void*),
extern "C" int(*)(const void*,const void*),
extern "C" void (*)(void*),
extern "C" void (*)(void*))
is being passed
void(*)(void*).
> This kind of several warnings I am getting.
>
> Thanks,
Apparently, you have a function called g_hash_table, whose third and
fourth
parameters are c-linkage (extern "C") function pointers
whereas you're passing a regular c++ function as one of those parameters.
The fix is to pass a pointer to a C linkage function.
This may involve changing the actual function to be extern "C"
as well as changing a local variable of the function pointer
to be extern "C".
Following is an example:
extern "C" int myfunc(void) { return 0; }
extern "C" {
typedef int (*myfunc_t)(void);
};
int testfunc( myfunc_t t);
void test(void) {
myfunc_t ptr = myfunc;
testfunc(ptr);
}
This will compile without warning. If you get rid of extern "C"
from the myfunc definition, you'll see the similar warning.
If you need to have a pointer variable to a function that's c-linkage
(like "ptr" above), you'll need to use typedef.
This affects, among others, the name mangling of those functions.
The names of extern "C" delcared functions won't get mangled.
Other than that, C linkage and C++ linkage have been compatible so far
on most platforms including Sun, so it usually works just fine.
But there's no guarantee that this won't change in the future.
--
#pragma ident "Seongbae Park, compiler, http://blogs.sun.com/seongbae/"


|