Jump to content

  • Log In with Google      Sign In   
  • Create Account


Does using a local struct as a functor work in Xcode


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 jwezorek   Crossbones+   -  Reputation: 1606

Like
0Likes
Like

Posted 21 January 2012 - 01:51 PM

I'm planning on porting some code from VS2010 to Apple world and just discovered that XCode doesn't support lambdas. Was wondering if as a work-around I could use local structs as functors? As discussed in this StackOverflow thread this is a C++11 feature, but was wondering if XCode happens to support it? (I don't currently own a mac, am just thinking ahead)

Sponsor:

#2 Calexus   Members   -  Reputation: 245

Like
0Likes
Like

Posted 21 January 2012 - 03:19 PM

xcode uses the GCC or LLVM compilers so it all depends on what versions of the compilers you have.
Exitus Acta Probat

#3 Cornstalks   Crossbones+   -  Reputation: 6966

Like
0Likes
Like

Posted 21 January 2012 - 03:29 PM

What Calexus said. If you want to find out, you can install a g++ compiler on your Windows machine (i.e. through MinGW or Cygwin) and try it out. I think g++ has more C++11 support than VS2010, iirc (speaking of the latest versions, of course).
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#4 jwezorek   Crossbones+   -  Reputation: 1606

Like
0Likes
Like

Posted 21 January 2012 - 04:13 PM

Wait so you can use XCode with whatever version of GCC you want? Because the guy in this thread is saying that if you want to use C++11 features you have to install GCC 4.6 and use that but from the command line or a 3rd party IDE e.g. Eclipse + CDT. Is this not right? -- because I kind of wanted to stick with XCode since I will be a newbie in Mac development.

I was thinking you had to use GCC 4.2 with XCode and was wondering if it supported passing local structs as functors to std::algorithms.

#5 Cornstalks   Crossbones+   -  Reputation: 6966

Like
1Likes
Like

Posted 21 January 2012 - 04:52 PM

In this blog post, a guy got X Code working with GCC 4.4, and a commentor says he followed the directions and, with a slight change, got it working with GCC 4.6. Your milage may vary, however.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#6 daviangel   Members   -  Reputation: 600

Like
1Likes
Like

Posted 21 January 2012 - 05:08 PM

For a list of C++11 features Clang currently supports, see C++ and C++'11 Support in Clang. Lambda expressions are currently not implemented.

Your only choice for now (until Clang devs implement lambda support) is using MacPorts' GCC 4.5/4.6 compilers.

The extra command-line option would be -std=c++0x (in the next version of Clang and GCC it will be the proper -std=c++11).

Personally, I find MacPorts to be essential to install on my Mac if I want to get the latest version of software that is unavailable any other way.

p.s. This shows how you would see and change the option in Xcode for the compiler you want to use for a newbie.
Don't talk about writing games, don't write design docs, don't spend your time on web boards. Sit in your house write 20 games when you complete them you will either want to do it the rest of your life or not * Andre Lamothe

#7 jwezorek   Crossbones+   -  Reputation: 1606

Like
0Likes
Like

Posted 21 January 2012 - 06:22 PM

For a list of C++11 features Clang currently supports, see C++ and C++'11 Support in Clang. Lambda expressions are currently not implemented.

So if you choose, "LLVM Compiler" you use CLang as your front end. Which version of CLang is that? -- because according to the link you provided Clang 2.9 supports "Local and unnamed types as template arguments" which is the question in my OP.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS