[Bf-committers] Using C++11 features in Blender source code?

Manuel Bellersen bellersenm at googlemail.com
Wed Mar 27 22:16:58 CET 2013


Hey Dalai,

It's not directly a project list. More a list of things I miss inside the
game engine.

Downsides of C++11…
Probably the worst downside is compiler support for it.
With GCC 4.7 / 4.8 and Clang 3.3 you probably won't have a problem. But MS
Visual Studio is again far behind :-(.
Here is a little comparison:
http://cpprocks.com/a-comparison-of-c11-language-support-in-vs2012-g-4-7-and-clang-3-1/
http://cpprocks.com/c11-compiler-support-shootout-visual-studio-gcc-clang-intel/

C++11 is fully backwards compatible.
Just your code might not be as clear as it should be ;-)
http://stackoverflow.com/questions/4326045/is-new-c-backward-compatible

In my Blender branch I used C++11 features and had no real problems so far.
In the beginning I had to fix some lines the compiler otherwise would have
seen as string literal operators:
http://blenderartists.org/forum/showthread.php?283156-Fix-Compiling-BGE-with-C-11-option-gives-errors


You are right. Most C code in the game engine is glue to Blender.
But sometimes I find things like assert.h, float.h, math.h, stddef.h,
stdlib.h, stdio.h, malloc, free…
Trying to figure out where the game engine starts drove me through a lot of
C - that scared me - and lead to the impression, that there is more in the
GE. But it looks quite clear. (I thought that Blender would be total C++ …).


Hi Mitchell,

MSVC 2008 sounds really bad.
I guess that means no C++11. Too bad.
In the code I already modified I used things like: auto,shared_ptr, for,
move, array, nullptr, constexpr - just to name some.


Thanks for your answers!

Cheers!
Manuel Bellersen


2013/3/27 Dalai Felinto <dfelinto at gmail.com>

> Hi Manuel,
> I need to re-visit your post to read it more through, but interesting
> initiative. For some of your projects you may want to drop on irc
> #bgecoders (or even #blendercoders) channel to bounce ideas before getting
> down to code. Mainly to smooth out future merges.
>
> Now to your topic:
> Could you elaborate on the downsides of using C++11? (backward
> incompatibility? Lack of compilers? )
> And the problems of mixing it up with the existent C++ code.
>
> Also BGE shouldn't have C code. As far as I can think of, the only part in
> C are the dependencies coming from Blender or code for the embedded BGE.
>
> Cheers,
> Dalai
> On Mar 27, 2013 7:52 AM, "Manuel Bellersen" <bellersenm at googlemail.com>
> wrote:
>
> > Hey there!
> >
> > I just got in contact with coding Blender, especially the internal game
> > engine.
> > (Here is my personal branch https://bitbucket.org/Urfoex/blender/
> > and a little write-up:
> >
> http://urfoex.blogspot.com/2013/03/bge-qt5-coding-blender-game-engine.html
> )
> >
> > I like to code using the new features of C++11.
> > But currently Blender isn't using C++11 anywhere.
> > (I think it is kind of funny because it uses Python 3.3 that came out
> > 29.09.2012
> > but doesn't use C++11 which showed up already a year earlier on
> > 12.08.2011.)
> >
> > So the question is:
> > Can I contribute code written using C++11 features?
> > Or am I forced to do the C & C++ mix I found (and fear)?
> >
> >
> > Best regards,
> > Manuel Bellersen
> > _______________________________________________
> > Bf-committers mailing list
> > Bf-committers at blender.org
> > http://lists.blender.org/mailman/listinfo/bf-committers
> >
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at blender.org
> http://lists.blender.org/mailman/listinfo/bf-committers
>


More information about the Bf-committers mailing list