• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to use inline functions
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: How to use inline functions
      • From: Nick Zitzmann <email@hidden>
    • Re: How to use inline functions
      • From: James Bucanek <email@hidden>
  • Prev by Date: Re: Core Data - NSFetchRequest Issue
  • Next by Date: Re: Code Signing and a Background Tool
  • Previous by thread: NSView/NSResponder returns YES
  • Next by thread: Re: How to use inline functions
  • Index(es):
    • Date
    • Thread