• 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
Re: how to pass arguments by reference
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to pass arguments by reference


  • Subject: Re: how to pass arguments by reference
  • From: Peter N Lewis <email@hidden>
  • Date: Thu, 11 Dec 2008 10:53:43 +0900

But the error when compiling is "parse error before & token".
Is passing by reference not allowed or is there any other syntax that I should follow?

References are a C++ feature.

Objective C++ works just fine, but you need to compile as Objective C++ by using an extension of .mm.

Since this is a pain, what I typically do is simply set the GCC 4.0 Language preferences to compile everything as Objective C++. Note that I changed this for Keyboard Maestro some versions back and I did a few tests and basically found no noticeable change in size or performance. I've also done this for an iPhone app with the same results so I don't see any reason not to do this in general as C++ is in general a cleaner language (with more junk stuck on, but you can ignore that).

What I can't figure out is why Xcode iPhone projects do not display the GCC 4.0 Language section in the settings (inexplicably, the section has now appeared in my own iPhone project, but it does not show up in newly created projects - bizarre!

Anyway, the solution is:

Don't use C++ features.
Use .mm (for all files that import your header!)
Switch to Compile Sources As: Objective C++
   [GCC_INPUT_FILETYPE = sourcecode.cpp.objcpp]

Enjoy,
   Peter.


-- Keyboard Maestro 3 Now Available! Now run macros from your iPhone with Keyboard Maestro Control!

Keyboard Maestro <http://www.keyboardmaestro.com/> Macros for your Mac
<http://www.stairways.com/>           <http://download.stairways.com/>
_______________________________________________

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


References: 
 >how to pass arguments by reference (From: Nick Rogers <email@hidden>)

  • Prev by Date: Re: The thread that starts by NSTask didn't clear up
  • Next by Date: Re: Countdown With NSTimer - Hours, Minutes, Seconds Remaining?
  • Previous by thread: Re: how to pass arguments by reference
  • Next by thread: IB Scroll View position problem
  • Index(es):
    • Date
    • Thread