# \-std=c++11 not being used/set properly with GCC 4.8.5

**URL:** https://discourse.cmake.org/t/std-c-11-not-being-used-set-properly-with-gcc-4-8-5/10767
**Category:** Usage
**Tags:** os:linux, comp:gcc
**Created:** [April 30, 2024, 6:11pm UTC](https://discourse.cmake.org/t/std-c-11-not-being-used-set-properly-with-gcc-4-8-5/10767 "2024-04-30T18:11:14Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bp7878](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/8e8cbc/32.png) [@bp7878](https://discourse.cmake.org/u/bp7878)
#### Post date: [April 30, 2024, 6:11pm UTC](https://discourse.cmake.org/t/std-c-11-not-being-used-set-properly-with-gcc-4-8-5/10767/1 "2024-04-30T18:11:14Z")

</div>

I’m working on an older project under RHEL 7 with GCC 4.8.5. I have cmake3 3.17.5 installed.

I’m building a shared library that is complaining about a for loop error:

```auto
 error: ‘for’ loop initial declarations are only allowed in C99 mode
   for (size_t i = 0;

```

in the libraries CMakeLists, I’m setting:

```auto
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS OFF)

```

I see the following is being set:

```auto
MakeFiles/3.17.5/CMakeCXXCompiler.cmake:set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "98")

```

I also have the following compiler flags set:

```auto
set(CPPFLAGS "-g -O2 -fPIC -pthread -DNET_LOG_MSG -fno-strict-aliasing -Wall -Wextra -Wno-unused -Wno-strict-aliasing -Werror=format-security -D_FORTIFY_SOURCE=2")

set(CMAKE_CXX_COMPILER "/usr/bin/g++")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CPPFLAGS} ") 
set(CMAKE_CXX_FLAGS_DEBUG "-U_FORTIFY_SOURCE -O0 -g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CPPFLAGS} -Wstrict-prototypes")
set(CMAKE_C_FLAGS_DEBUG "-U_FORTIFY_SOURCE -O0 -g")
set(CMAKE_C_FLAGS_RELEASE "-O3")

```

I’m sure I’m missing something here, but in other similar projects, I have essentially the same thing which has worked for quite some time. Admittedly, I haven’t been working much under el7, mostly under el8, where this code compiles fine. Of course the computed default there is 14.

Any help is greatly appreciated!

EDIT: This was a .c file so I needed CMAKE\_C\_STANDARD set.
