# Time for C++11?

**URL:** <https://community.zeek.org/t/time-for-c-11/3159>\
**Category:** Development\
**Tags:** development\
**Created:** [June 23, 2014, 3:43pm UTC](https://community.zeek.org/t/time-for-c-11/3159 "2014-06-23T15:43:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [June 23, 2014, 3:43pm UTC](https://community.zeek.org/t/time-for-c-11/3159/1 "2014-06-23T15:43:59Z")

</div>

I'm guessing (and hearing 🙂 that most of us would like to start  
using C++11 in Bro's code base. With compiler support now apparently  
broad and robust, and our 2.4 dev cycle starting, I'm thinking it may  
be a good time now to make the move.

What I propose is:

&nbsp;&nbsp;&nbsp;&nbsp;- We decide which minimum versions of GCC and clang (and their  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stdlibs) we need to require.

&nbsp;&nbsp;&nbsp;&nbsp;- As a double-check, we survey the main OS distributions and make  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sure they offer that by now.

&nbsp;&nbsp;&nbsp;&nbsp;- We put cmake magic in place to check for these versions. [1]

&nbsp;&nbsp;&nbsp;&nbsp;- We switch to compiling all C++ code with -std=c++11.

&nbsp;&nbsp;&nbsp;&nbsp;- We allow use of C++11 features in new code.

&nbsp;&nbsp;&nbsp;&nbsp;- Over time, we modernize old code as appropiate. Probably just  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ad-hoc for the most part, as we touch it; but maybe we can also  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;put some time towards systematic changes, like with some of  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clang's transition tools.

Opinions?

Robin

[1] While we are at that, I suggest we also (re-)up the cmake version.  
Probably hard to find a C++11 tool chain with a many-years-old cmake.

---

<div class="post-metadata">

**Author:** ![Matthias\_Vallentin1](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/matthias_vallentin1/32/596_2.png) [@Matthias\_Vallentin1](https://community.zeek.org/u/Matthias_Vallentin1)\
**Post date:** [June 23, 2014, 6:13pm UTC](https://community.zeek.org/t/time-for-c-11/3159/2 "2014-06-23T18:13:07Z")

</div>

> I'm guessing (and hearing 🙂 that most of us would like to start  
> using C++11 in Bro's code base. With compiler support now apparently  
> broad and robust, and our 2.4 dev cycle starting, I'm thinking it may  
> be a good time now to make the move.

I would go one step further: let's aim for C++14. In many ways C++11 was  
just a half-hearted attempt to modernize the language. For example,  
automatic return type deduction and lambdas are just incomplete in  
C++11.

> &nbsp;&nbsp;&nbsp;&nbsp;- We decide which minimum versions of GCC and clang (and their  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stdlibs) we need to require.

To be useful, we'd need gcc 4.9 anyway (because everything below has a  
broken implementation of std::regex) and 4.9 also supports the most  
important C++14 features (except for variable templates, which I think  
we can live without for a while). We'd get a way with Clang 3.3 but  
Clang 3.4 already has full C++14 support. Therefore, I suggest we  
require GCC 4.9 and Clang 3.4.

> &nbsp;&nbsp;&nbsp;&nbsp;- As a double-check, we survey the main OS distributions and make  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sure they offer that by now.

Your install-clang script should give us some mileage when we use Clang,  
GCC is often more tightly integrated into the distribution package  
managers.

> &nbsp;&nbsp;&nbsp;&nbsp;- We put cmake magic in place to check for these versions. [1]

Since version 3.0 CMake supports explicit feature enumeration of  
available C++ features [1]. This may obviate the need of a specific  
compiler version, albeit a bit of fiddling.

> &nbsp;&nbsp;&nbsp;&nbsp;- We switch to compiling all C++ code with -std=c++11.

Or -std=c++1y :-).

> &nbsp;&nbsp;&nbsp;&nbsp;- We allow use of C++11 features in new code.

Further, I'm sure we could replace many existing hacks and workarounds  
in the existing code base.

> &nbsp;&nbsp;&nbsp;&nbsp;- Over time, we modernize old code as appropiate. Probably just  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ad-hoc for the most part, as we touch it; but maybe we can also  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;put some time towards systematic changes, like with some of  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;clang's transition tools.

Tools sound interesting for existing code. Looking forward, it would  
also be useful to come up with a few guidelines, such as avoiding owning  
naked pointers, preferring value semantics where possible, etc.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Matthias

[1] [c++ - How to detect C++11 support of a compiler with CMake - Stack Overflow](http://stackoverflow.com/a/20165220/1170277)

---

<div class="post-metadata">

**Author:** ![Vlad\_Grigorescu1](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@Vlad\_Grigorescu1](https://community.zeek.org/u/Vlad_Grigorescu1)\
**Post date:** [June 23, 2014, 6:17pm UTC](https://community.zeek.org/t/time-for-c-11/3159/3 "2014-06-23T18:17:07Z")

</div>

If the OpenSuSE build service idea moves forward, does that mean we can be  
stricter with the requirements? Hopefully, people should be able to install  
a package except if they want to try master or try a certain branch.

&nbsp;&nbsp;--Vlad

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [June 23, 2014, 6:35pm UTC](https://community.zeek.org/t/time-for-c-11/3159/4 "2014-06-23T18:35:36Z")

</div>

I was expecting you to propose that. 🙂

I'm very reluctant to rely on a cutting-edge compiler for compiling  
Bro. There's really not much worse for an open-source tool than  
downloading the code and then realizing that your system's compiler is  
too old to handle it. I think we need to ensure that most people will  
be able to directly download and compile Bro, without having to worry  
about much else. My hope is that we are that point now for C++11  
(potentially by skipping use of some specific features), but clang 3.4  
and gcc 4.9 sound like a stretch to me ... We should probably reverse  
the order of my list: survey OSs first what they ship these days, then  
decide what we are fine requiring.

This looks like a nice C++11 summary for gcc 4.8 and clang 3.3:

&nbsp;&nbsp;&nbsp;&nbsp;[C++11 compiler support shootout: Visual Studio, GCC, Clang, Intel](http://cpprocks.com/c11-compiler-support-shootout-visual-studio-gcc-clang-intel/)

Robin

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [June 23, 2014, 6:37pm UTC](https://community.zeek.org/t/time-for-c-11/3159/5 "2014-06-23T18:37:20Z")

</div>

For many people that might remain a matter of taste. Personally, for  
example, I usually go for the source even if a project offers RPMs. So  
I'm not sure I would relax requirements just because we have  
more/better binaries.

Robin

---

<div class="post-metadata">

**Author:** ![Vlad\_Grigorescu1](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@Vlad\_Grigorescu1](https://community.zeek.org/u/Vlad_Grigorescu1)\
**Post date:** [June 23, 2014, 6:58pm UTC](https://community.zeek.org/t/time-for-c-11/3159/6 "2014-06-23T18:58:05Z")

</div>

Fair enough.

For surveying the environment, you can use DistroWatch. For example, to see which distros have gcc 4.9: [http://distrowatch.com/search.php?pkg=gcc&pkgver=4.9.0#pkgsearch](http://distrowatch.com/search.php?pkg=gcc&pkgver=4.9.0#pkgsearch)

The main stragglers seem to be RHEL and Ubuntu LTS. Ubuntu 12.04 has 4.6.3 and RHEL 6.5 has 4.4.7.

I believe RHEL users can install a devtoolset, which has a more recent version installed under /opt, but we’ll have to make sure CMake checks there.

–Vlad

---

<div class="post-metadata">

**Author:** ![Daniel\_Thayer](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Daniel\_Thayer](https://community.zeek.org/u/Daniel_Thayer)\
**Post date:** [June 23, 2014, 7:01pm UTC](https://community.zeek.org/t/time-for-c-11/3159/7 "2014-06-23T19:01:37Z")

</div>

According to distrowatch:

RHEL 7 gcc 4.8.2  
RHEL 6.5 gcc 4.4.7  
debian 7 gcc 4.7.2  
ubuntu 14.04 LTS gcc 4.8.2  
ubuntu 12.04 LTS gcc 4.6.3  
FreeBSD 10 gcc 4.7.3  
FreeBSD 9.2 gcc 4.6.4

---

<div class="post-metadata">

**Author:** ![Matthias\_Vallentin1](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/matthias_vallentin1/32/596_2.png) [@Matthias\_Vallentin1](https://community.zeek.org/u/Matthias_Vallentin1)\
**Post date:** [June 23, 2014, 7:16pm UTC](https://community.zeek.org/t/time-for-c-11/3159/8 "2014-06-23T19:16:46Z")

</div>

> \> I would go one step further: let's aim for C++14.
> 
> I was expecting you to propose that. 🙂

And I knew your answer beforehand :-).

> I'm very reluctant to rely on a cutting-edge compiler for compiling  
> Bro. There's really not much worse for an open-source tool than  
> downloading the code and then realizing that your system's compiler is  
> too old to handle it.

I fully understand the concerns regarding our users: it's unreasonable  
to request manual bootstrapping of compilers or devoting extensive time  
just to install Bro. My main point was from a developer pointer of view:  
why drive with the handbrake on if it's not necessary.

That said, if we're well aware of the limitations of C++11, I don't see  
an issue with this "compromise."

> We should probably reverse the order of my list: survey OSs first what  
> they ship these days, then decide what we are fine requiring.

Agreed. GCC 4.8 and Clang 3.3 are hopefully well-supported by most  
distributions by the end of the year.

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Matthias

---

<div class="post-metadata">

**Author:** ![johanna](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@johanna](https://community.zeek.org/u/johanna)\
**Post date:** [June 23, 2014, 7:50pm UTC](https://community.zeek.org/t/time-for-c-11/3159/9 "2014-06-23T19:50:23Z")

</div>

At least for FreeBSD 10 this is wrong. By default, it ships with clang3.3 and has no gcc installed in the base system.

---

<div class="post-metadata">

**Author:** ![johanna](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@johanna](https://community.zeek.org/u/johanna)\
**Post date:** [June 23, 2014, 7:59pm UTC](https://community.zeek.org/t/time-for-c-11/3159/10 "2014-06-23T19:59:26Z")

</div>

I am generally all in favor for that. The only problem I see with this is, that a number of people still seem to be using RHEL 6 or similar to run Bro - at least I think I remember a few people in the last few months mentioning that on IRC.

However, if we offer binary packages for these old systems (as Vlad mentioned in his email) that might be ok. You still can install it without fidgeting on older systems that you might have to use in production and we still get to use the new features.

---

<div class="post-metadata">

**Author:** ![Vlad\_Grigorescu1](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@Vlad\_Grigorescu1](https://community.zeek.org/u/Vlad_Grigorescu1)\
**Post date:** [June 23, 2014, 8:27pm UTC](https://community.zeek.org/t/time-for-c-11/3159/11 "2014-06-23T20:27:15Z")

</div>

Is it worth conducting a survey on the mailing list of what distros people are using? If we spin it the correct way (maybe something like “We’re reevaluating what distros we test and fully support”) and make it anonymous, even the corporate users might chime in.

I figure that between this discussion, and the one on revisiting our packages, having some more information would be useful.

–Vlad

---

<div class="post-metadata">

**Author:** ![robin](https://yyz1.discourse-cdn.com/flex011/user_avatar/community.zeek.org/robin/32/599_2.png) [@robin](https://community.zeek.org/u/robin)\
**Post date:** [June 24, 2014, 12:13am UTC](https://community.zeek.org/t/time-for-c-11/3159/12 "2014-06-24T00:13:40Z")

</div>

Yeah, that's a good idea. Is anybody up for creating a SurveyMonkey or  
Google Form that lists the most common OS/distros so that we can send  
a link to the list?

Robin

---

<div class="post-metadata">

**Author:** ![Vlad\_Grigorescu1](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@Vlad\_Grigorescu1](https://community.zeek.org/u/Vlad_Grigorescu1)\
**Post date:** [June 24, 2014, 12:34am UTC](https://community.zeek.org/t/time-for-c-11/3159/13 "2014-06-24T00:34:42Z")

</div>

I got it.

---

<div class="post-metadata">

**Author:** ![Vlad\_Grigorescu1](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@Vlad\_Grigorescu1](https://community.zeek.org/u/Vlad_Grigorescu1)\
**Post date:** [June 24, 2014, 2:15am UTC](https://community.zeek.org/t/time-for-c-11/3159/14 "2014-06-24T02:15:27Z")

</div>

The SurveyMonkey logic is quite limited, but here’s a first stab:

[https://www.surveymonkey.com/create/survey/preview?sm=sMxABvZfS7kFp1nczfE1LmaagTQleFF7GNi5q6aW\_2Fnz7aihojblvATta4i5un\_2FS5](https://www.surveymonkey.com/create/survey/preview?sm=sMxABvZfS7kFp1nczfE1LmaagTQleFF7GNi5q6aW_2Fnz7aihojblvATta4i5un_2FS5)

Any major distros that I forgot? Or that I can remove?

Do we know what architectures Bro currently supports? Apart from the obvious x86 and x86-64, does it support PowerPC? Is it worth asking if there’s another architecture they’d like to see supported (maybe ARM)?

–Vlad

---

<div class="post-metadata">

**Author:** ![Daniel\_Thayer](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Daniel\_Thayer](https://community.zeek.org/u/Daniel_Thayer)\
**Post date:** [June 24, 2014, 3:59am UTC](https://community.zeek.org/t/time-for-c-11/3159/15 "2014-06-24T03:59:44Z")

</div>

You left out Scientific Linux, and FreeBSD 8.4

---

<div class="post-metadata">

**Author:** ![Clark\_Gilbert](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@Clark\_Gilbert](https://community.zeek.org/u/Clark_Gilbert)\
**Post date:** [June 24, 2014, 7:02am UTC](https://community.zeek.org/t/time-for-c-11/3159/16 "2014-06-24T07:02:35Z")

</div>

+1 for ARM

-Gilbert

---

<div class="post-metadata">

**Author:** ![Vlad\_Grigorescu1](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@Vlad\_Grigorescu1](https://community.zeek.org/u/Vlad_Grigorescu1)\
**Post date:** [June 24, 2014, 10:49am UTC](https://community.zeek.org/t/time-for-c-11/3159/17 "2014-06-24T10:49:12Z")

</div>

Well, I have this comment under "What Linux distro do you run Bro on?":  
Note: Please select the "parent" distro if yours isn't listed (e.g. if  
you're running Scientific Linux, select RHEL)

Is there any functional difference between Scientific and RHEL, in terms of  
package versions? Since their stated goal is "as close to the commercial  
enterprise distribution as we can get it," I figured it was a safe bet  
leaving it off. I can certainly add it, though.

and FreeBSD 8.4

Ah, good catch. That's what I get for relying on the DistroWatch page...  
Added a few more FreeBSD versions.

&nbsp;&nbsp;--Vlad

---

<div class="post-metadata">

**Author:** ![Daniel\_Thayer](https://avatars.discourse-cdn.com/v4/letter/d/8dc957/32.png) [@Daniel\_Thayer](https://community.zeek.org/u/Daniel_Thayer)\
**Post date:** [June 24, 2014, 12:45pm UTC](https://community.zeek.org/t/time-for-c-11/3159/18 "2014-06-24T12:45:26Z")

</div>

Maybe you should just combine RHEL and CentOS into one entry, like this:

RHEL/CentOS/Scientific Linux

---

<div class="post-metadata">

**Author:** ![Vlad\_Grigorescu1](https://avatars.discourse-cdn.com/v4/letter/v/f9ae1b/32.png) [@Vlad\_Grigorescu1](https://community.zeek.org/u/Vlad_Grigorescu1)\
**Post date:** [June 24, 2014, 1:20pm UTC](https://community.zeek.org/t/time-for-c-11/3159/19 "2014-06-24T13:20:52Z")

</div>

Good idea, thanks. Updated.

---

<div class="post-metadata">

**Author:** ![johanna](https://avatars.discourse-cdn.com/v4/letter/j/50afbb/32.png) [@johanna](https://community.zeek.org/u/johanna)\
**Post date:** [June 24, 2014, 2:46pm UTC](https://community.zeek.org/t/time-for-c-11/3159/20 "2014-06-24T14:46:05Z")

</div>

The last time I tried (a few months ago), Bro worked fine on arm. On the opens use build service, one of the arm builds also went through. From time to time we get people on IRC compiling it on their raspberry pi's - but those are kind of too slow to actually use it.

[Next page](https://community.zeek.org/t/time-for-c-11/3159.md?page=2)
