How to use inline functions
How to use inline functions
- Subject: How to use inline functions
- From: Oleg Krupnov <email@hidden>
- Date: Thu, 13 Jan 2011 17:21:45 +0200
Hi,
I realize that my question has no relation to Cocoa, but it's still
the place where I can get the fastest answer :)
In several places in my app I check if the user has a valid license
for my app. I'd like to make cracking the app somewhat more difficult
and rather than calling -[license isValid], I want to call
isLicenseValid(), and inline this function, so that the entire code of
this function is duplicated in the binary in each place where I make
the call to isLicenseValid().
How should I declare the function in this case?
I have made an h-file and put the body of the function there:
(LicenseValidation.h)
inline bool isLicenseValid()
{
...
return isValid;
}
But when I #include this h-file into an m-file where I need it, the
compiler says "Symbol not found, _isLicenseValid referenced from ..."
So I added "static" to the declaration :
static inline bool isLicenseValid()
{
...
return isValid;
}
No more errors, but I am not sure if in this case the compiler will
produce as many instances of the code as there are calls to the
function. Will it?
Thanks!
P.S. I am using a GCC compiler
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden