Home > Zombie Outhouse > Zombie Outhouse Development Part 3

Zombie Outhouse Development Part 3

Zombie Outhouse Development Part 3: Converting from C# to C++

While the official programming language for the iPhone is Objective-C, you can use C/C++ within it.  I prefer to work in C++ and try to avoid Objective-C at all costs.

To take the path from C# to C++ I used Tangible Software’s Instant C++ software.  The conversion of the files was fairly quick but that was the easy part.

There was a lot of manual work in cleaning up the converted files.  I removed all namespace references and had to make sure the classes compiled cleanly.  I also had to recreate a lot of the core XNA classes/structs such as Rectangle, Color, Point, etc.  I already had some of those classes converted a year ago for a previous test when I wanted to keep the API very similar to XNA.

Some issues to keep in mind when writing C# code that you plan to convert to C++:

Delegates – there is no built in support for delegates in C++ but there are a few solutions using libraries such as Boost.  I decided to use a common base class and a standard virtual function pointer and just store pointers to the objects and their callback functions as my “delegate” pointer to keep things simple for now.

ArrayList vs List – Avoid ArrayList collections and use List collections which convert fairly cleanly to std::vector.

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: