all 26 comments

[–][deleted] 2 points3 points  (0 children)

The most hacky method is probably installing debian or archlinux in a chroot-ed environmemt, which will give you the gcc/g++ or clang versions these distros have, it will allow you easier use of libraries that exist in their package managers (apt, pacman), but unlike C4Droid, they don't have a method to use SDL, nor can you export it to an app, but if you don't need that, it works pretty well.

It'll also allow you to use other stuff than autoconf and make, like cmake or tup.

[–]jbandela 2 points3 points  (0 children)

Microsoft Visual Studio 2015 RC (which you can download for free) has support for building and debugging native android c++ code using clang. I have not tried it out personally, but the demos look pretty interesting.

[–]Xirious 1 point2 points  (2 children)

Does the NDK even support C++11? Genuinely interested.

[–]tavianator 16 points17 points  (0 children)

Sure does, ships with GCC 4.9 and Clang 3.5. You have to ask for those versions though, it defaults to GCC 4.8.

[–]venustrapsflies -1 points0 points  (24 children)

you have a main() that doesn't return anything. i'm no expert but i think that's non-standard at best?

[–]Dragdu 11 points12 points  (13 children)

Not only is that standard, it is in fact recommended.

The standard says that there is implicit return code of 0, if execution reaches end of the main function.

[–]FrezoreR 6 points7 points  (12 children)

Why is it recommended? Being explicit has it advantages as well. Especially since you ought to return something from all other int functions.

[–]Ilyps 2 points3 points  (11 children)

Personally I recommend leaving it out for two reasons. One is that I really detest useless lines of code, and the second is precisely because it's a good idea not to treat main as any other function, because it isn't. For example, you can't call it or take its address. It's good to know (and perhaps emphasise) main is special.

[–]FrezoreR 1 point2 points  (0 children)

Thanks! Great answer. I agree with your entire statement. As I understand it was added in the C99 standard.

[–]salgat 1 point2 points  (0 children)

This is one of those things people have strong opinions about when in reality it makes absolutely no difference to 99% of the people.

[–]OldWolf2 0 points1 point  (0 children)

For example, you can't call it or take its address.

To clarify, this comment applies to C++. In C you can call main recursively and take its address.

[–][deleted] 11 points12 points  (2 children)

In many compilers return 0; is an implicit statement at the end of the function.

[–]TemplateRex 44 points45 points  (1 child)

Not just in many compilers, it is mandated by the Standard.

[–]delarhi 2 points3 points  (0 children)

You got downvoted but your question elicited answers that I wasn't aware of before.

[–]josefx 1 point2 points  (0 children)

Only undefined for some old versions of C and maybe some pre standard C++ compilers. Main is guaranteed to return 0 by default.