Re: Question about weak linking?
Re: Question about weak linking?
- Subject: Re: Question about weak linking?
- From: Chris Espinosa <email@hidden>
- Date: Thu, 6 May 2004 08:25:01 -0700
On May 6, 2004, at 4:22 AM, Philip Aker wrote:
On Thursday, May 6, 2004, at 00:33 US/Pacific, Trenton Schulz wrote:
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.
It is, however, defined in the copy of AvailabilityMacros.h in the
Jaguar SDK; you should target the SDK if you're compiling
cross-platform code like this, even if you're building on the intended
target OS.
Chris
_______________________________________________
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.