Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C or C++ for cross-platform mobile development?

Tags:

c++

android

ios

For a cross-platform project on iOS, Android and Windows I originally wrote some underlying classes in C++. From what I understand however, I will have to write an objective-C wrapper to allow the swift iPhone project to work in xcode. Would it make more sense then that I simply rewrite all of the original framework in C or would simply wrapping it in C be a better solution. No problem either way just attempting to determine the best way to keep the code valid.

Also telling me to use a cross-platform mobile development SDK is not helpful.

like image 689
kdgwill Avatar asked Apr 15 '16 13:04

kdgwill


People also ask

Is C good for mobile apps?

Different languages for different apps For native mobile app development, use a language that works with iOS and Android operating systems. Some popular languages for this type of development include Objective-C, Swift, and Java.

Is C and C++ cross compatible?

C/C++ is considered a cross-platform language, but great care must be taken to ensure that the source code is indeed cross-platform, using only C/C++ supported by all target compilers and containing little or no conditionally-included platform or compiler-specific code.


1 Answers

I would recommend writing in C++ 11. It's more modern, has more support online, and you can even compile everything with Cmake. There are many tools out there to help you with this. My company is using this to develop a framework that compiles on the following platforms:

iOS, Mac OS X, Android (ARM, x86, x64), Windows (x86, x64), Linux (x86, x64)

You can also find a tool here to help you with cross platform toolchains, so that code you compile is easily ready for multiple platforms: https://github.com/ruslo/polly

like image 89
dokun1 Avatar answered Sep 18 '22 23:09

dokun1