Re: Question about weak linking?
Re: Question about weak linking?
- Subject: Re: Question about weak linking?
- From: Glen Low <email@hidden>
- Date: Fri, 7 May 2004 08:00:05 +0800
Trenton:
On 06/05/2004, at 3:33 PM, Trenton Schulz wrote:
Hi,
Someone from carbon-development suggest I pass this along to the
Xcode-Users list, so here you go:
Begin forwarded message:
Let's say I have this program where I'm trying to do weak linking:
#include <Carbon/Carbon.h>
void use_secure_keyboard(bool b)
{
#if (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
if(b) {
if (EnableSecureEventInput)
EnableSecureEventInput();
} else {
if (DisableSecureEventInput)
DisableSecureEventInput();
}
#else
(void*)b;
#endif
}
int main()
{
use_secure_keyboard(true);
return 0;
}
Now if I compile this program as a C program it works fine. But if I
compile it as a C++ program I get this messages:
main.cpp: In function `void use_secure_keyboard(bool)':
main.cpp:7: warning: the address of `OSStatus
EnableSecureEventInput()', will
always be `true'
main.cpp:10: warning: the address of `OSStatus
DisableSecureEventInput()', will
always be `true'
And sure enough, if you run it on Jaguar it does crash.
I'm guessing it might possibly be the name mangling, but it comes
from Carbon so it should know EnableSecureEventInput is a C function.
Is there anything obvious/non-obvious I'm missing? I really need to
this to work inside a C++ context.
Are the functions EnableSecureEventInput and DisableSecureEventInput
really weak-linked? You can check using nm -mg executable on the
command line.
If it is a genuine C++ bug, you could try putting the offending code in
an extern C { } construct.
Cheers, Glen Low
---
pixelglow software | simply brilliant stuff
www.pixelglow.com
_______________________________________________
xcode-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/xcode-users
Do not post admin requests to the list. They will be ignored.