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 (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++11to the additional build options did not change the situation
here is the source of the minimal C++ example:
#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

