Re: Question about weak linking?
Re: Question about weak linking?
- Subject: Re: Question about weak linking?
- From: Philip Aker <email@hidden>
- Date: Thu, 06 May 2004 04:22:05 -0700
On Thursday, May 6, 2004, at 00:33 US/Pacific, 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.
Thanks in advance,
Maybe if you tried:
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2
MAC_OS_X_VERSION_10_3 isn't defined in Jaguar.
Philip Aker
http://www.aker.ca
_______________________________________________
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.