# Using C++11 (and later) standard library

**URL:** <https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037>\
**Category:** Programming\
**Tags:** c-cpp\
**Created:** [November 17, 2025, 10:06am UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037 "2025-11-17T10:06:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lukas\_Kimme](https://avatars.discourse-cdn.com/v4/letter/l/FF8800/32.png) [@Lukas\_Kimme](https://community.br-automation.com/u/Lukas_Kimme)\
**Post date:** [November 17, 2025, 10:06am UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/1 "2025-11-17T10:06:42Z")

</div>

Hi community,

I was trying to compile a minimal example of a C++ program using a function from the standard library, that is available only in C++11 and newer, namely `std::log2` from the `cmath` header. However, I am getting an error `‘log2’ is not a member of ‘std’; did you mean ‘log’?` when compiling.

**Question** : Why is `std::log2` not available after `#include <cmath>`? Am I missing something (build options, …)?

Some related info:

- project for reference: [testCppStd.zip](https://community.br-automation.com/uploads/short-url/kjTU7bxIRLlGD8sFdbxsKS4D8Lt.zip) (37.0 KB) (AS6.3, AR 6.4.2)
- program appears to be compiled with C++ \>= 11, at least `static_assert(__cplusplus >= 201103L, “This code requires C++11 or later”);` does not cause a compile error
- adding `-std=c++11` to the additional build options did not change the situation

here is the source of the minimal C++ example:

```auto
#include <bur/plctypes.h>

#ifdef _DEFAULT_INCLUDES
    #include <AsDefault.h>
#endif

static_assert(__cplusplus >= 201103L, "This code requires C++11 or later");

#include <cmath>

// amount of memory to be allocated for heap storage must be specified for every ANSI C++ program with the bur_heap_size variable
unsigned long bur_heap_size = 0xFFFF; 

void _CYCLIC ProgramCyclic(void)
{
    double a = std::log2(4.0);
    a = a + a; // silence "unused variable"
}

```

Best regards

Lukas

---

<div class="post-metadata">

**Author:** ![christoph.hilchenbac](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christoph.hilchenbac/32/423_2.png) [@christoph.hilchenbac](https://community.br-automation.com/u/christoph.hilchenbac)\
**Post date:** [November 17, 2025, 12:50pm UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/2 "2025-11-17T12:50:24Z")

</div>

Hello,

Unfortunately, I can’t say.

But you can implement it by yourself:

```auto
#define log2(x) (log (x) / _M_LN2)

```

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/e/efb35f8cf15dba2804906f3e6fc378619240b824.png)

---

<div class="post-metadata">

**Author:** ![Lukas\_Kimme](https://avatars.discourse-cdn.com/v4/letter/l/FF8800/32.png) [@Lukas\_Kimme](https://community.br-automation.com/u/Lukas_Kimme)\
**Post date:** [November 17, 2025, 1:30pm UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/3 "2025-11-17T13:30:42Z")

</div>

Thanks Christoph, this is a workaround for the specific case, sure.

However, `log2` was merely chosen as a more or less arbitrary example for any “new” function in `std` from `<cmath>`. Others, like `std::trunc` etc. show the same behavior. So code relying on a recent std-lib will fail, that is my point.

To check if this is a more general behavior, I tried to use `std::unordered_map` from the `<unordered_map>` header which compiled without problems. So there are C++11 std-lib features that work as expected.

---

<div class="post-metadata">

**Author:** ![christoph.hilchenbac](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christoph.hilchenbac/32/423_2.png) [@christoph.hilchenbac](https://community.br-automation.com/u/christoph.hilchenbac)\
**Post date:** [November 17, 2025, 1:50pm UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/4 "2025-11-17T13:50:09Z")

</div>

it looks like ‘log2’ can be used without std:: namespace 🙂

 ![image](https://europe1.discourse-cdn.com/brcommunity/original/2X/1/18e0e00c407209c534999fc2768cf72cc4d5df61.png)

and this is because cmath first includes math.h and then defines the std namespace.

But according to C++ standard std::log2 should work as well.

@Lukas_Kimme : I will clarify this with B&R headquarter and come back to you.

---

<div class="post-metadata">

**Author:** ![Lukas\_Kimme](https://avatars.discourse-cdn.com/v4/letter/l/FF8800/32.png) [@Lukas\_Kimme](https://community.br-automation.com/u/Lukas_Kimme)\
**Post date:** [December 15, 2025, 1:16pm UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/5 "2025-12-15T13:16:52Z")

</div>

@christoph.hilchenbac, I guess there are no updates yet?

---

<div class="post-metadata">

**Author:** ![christoph.hilchenbac](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christoph.hilchenbac/32/423_2.png) [@christoph.hilchenbac](https://community.br-automation.com/u/christoph.hilchenbac)\
**Post date:** [December 15, 2025, 1:57pm UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/6 "2025-12-15T13:57:11Z")

</div>

unfortunately not yet. It is still being processed by R&D.

---

<div class="post-metadata">

**Author:** ![kovarj](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/kovarj/32/537_2.png) [@kovarj](https://community.br-automation.com/u/kovarj)\
**Post date:** [January 5, 2026, 8:58am UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/7 "2026-01-05T08:58:28Z")

</div>

Hi @christoph.hilchenbac , I marked your reply as a solution, please update us with findings from R&D.

---

<div class="post-metadata">

**Author:** ![christoph.hilchenbac](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christoph.hilchenbac/32/423_2.png) [@christoph.hilchenbac](https://community.br-automation.com/u/christoph.hilchenbac)\
**Post date:** [January 5, 2026, 9:24am UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/8 "2026-01-05T09:24:30Z")

</div>

The issue is currently being investigated under **QCAS-4148**.

---

<div class="post-metadata">

**Author:** ![christoph.hilchenbac](https://dub1.discourse-cdn.com/brcommunity/user_avatar/community.br-automation.com/christoph.hilchenbac/32/423_2.png) [@christoph.hilchenbac](https://community.br-automation.com/u/christoph.hilchenbac)\
**Post date:** [August 20, 2026, 7:32am UTC](https://community.br-automation.com/t/using-c-11-and-later-standard-library/9037/9 "2026-08-20T07:32:38Z")

</div>

Update:

**QCAS-4148** : CASE-59277 - using std namespace in C++ returns error during compilation - Status: _Corrective action(s) scheduled_  
This problem will be solved with a new GCC version planned for AS 6.9.
