'log2' is not a member of 'std'

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

'log2' is not a member of 'std'

Jan Stary
This is MacOSX 10.6.8 running various compilers provided by MacPorts.
Compiling the following C++ source

        #include <cmath>

        int main(void)
        {
                double d = std::log2(2.3456789f);
                return 0;
        }

results in

        'log2' is not a member of 'std'.

This happens with the system g++, which is i686-apple-darwin10-g++-4.2.1,
each of g++-4.0 g++-4.2 g++-mp-5 g++-mp-6, and with clang++-mp-3.4;
in each case, I am compiling as $CXX -std=c++11 prog.c

Apparently, there is some relatively recent turmoil about the C++ libs;
I don't know much c++ but find myself compiling some third party C++ code.
Am I missing something obvious?

        Jan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'log2' is not a member of 'std'

Jean-Francois Gobin
Jan, 

Could you test with the file renamed as « prog.cc »? I remember that gcc is picky about the extension.

Jean
 


Le 2 juil. 2017 à 12:28, Jan Stary <[hidden email]> a écrit :

This is MacOSX 10.6.8 running various compilers provided by MacPorts.
Compiling the following C++ source

#include <cmath>

int main(void)
{
double d = std::log2(2.3456789f);
return 0;
}

results in

'log2' is not a member of 'std'.

This happens with the system g++, which is i686-apple-darwin10-g++-4.2.1,
each of g++-4.0 g++-4.2 g++-mp-5 g++-mp-6, and with clang++-mp-3.4;
in each case, I am compiling as $CXX -std=c++11 prog.c

Apparently, there is some relatively recent turmoil about the C++ libs;
I don't know much c++ but find myself compiling some third party C++ code.
Am I missing something obvious?

Jan


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'log2' is not a member of 'std'

Jan Stary
On Jul 02 12:35:25, [hidden email] wrote:
> Could you test with the file renamed as « prog.cc <http://prog.cc/> »?
> I remember that gcc is picky about the extension.

Same thing.

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'log2' is not a member of 'std'

Kenneth F. Cunningham
In reply to this post by Jan Stary
See this as well:

<https://trac.macports.org/ticket/53226>

Ken

On 2017-07-02, at 3:28 AM, Jan Stary wrote:

> This is MacOSX 10.6.8 running various compilers provided by MacPorts.
> Compiling the following C++ source
>
> #include <cmath>
>
> int main(void)
> {
> double d = std::log2(2.3456789f);
> return 0;
> }
>
> results in
>
> 'log2' is not a member of 'std'.
>
> This happens with the system g++, which is i686-apple-darwin10-g++-4.2.1,
> each of g++-4.0 g++-4.2 g++-mp-5 g++-mp-6, and with clang++-mp-3.4;
> in each case, I am compiling as $CXX -std=c++11 prog.c
>
> Apparently, there is some relatively recent turmoil about the C++ libs;
> I don't know much c++ but find myself compiling some third party C++ code.
> Am I missing something obvious?
>
> Jan
>

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'log2' is not a member of 'std'

Joshua Root-8
In reply to this post by Jan Stary
> This is MacOSX 10.6.8 running various compilers provided by MacPorts.
> Compiling the following C++ source
>
> #include <cmath>
>
> int main(void)
> {
> double d = std::log2(2.3456789f);
> return 0;
> }
>
> results in
>
> 'log2' is not a member of 'std'.
>
> This happens with the system g++, which is i686-apple-darwin10-g++-4.2.1,
> each of g++-4.0 g++-4.2 g++-mp-5 g++-mp-6, and with clang++-mp-3.4;
> in each case, I am compiling as $CXX -std=c++11 prog.c
>
> Apparently, there is some relatively recent turmoil about the C++ libs;
> I don't know much c++ but find myself compiling some third party C++ code.
> Am I missing something obvious?

Well the Xcode-supplied g++s and clang would be using the system
libstdc++, which doesn't support C++11, and std::log2 is a C++11 feature.

The g++-mp variants should support it, but seemingly don't because of
the bug that Ken mentioned, which should be fixed in GCC 7.

Clang can support C++11 if you use -stdlib=libc++.

- Josh

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'log2' is not a member of 'std'

Ryan Schmidt-24

On Jul 2, 2017, at 12:28, Joshua Root wrote:

>> This is MacOSX 10.6.8 running various compilers provided by MacPorts.
>> Compiling the following C++ source
>> #include <cmath>
>> int main(void)
>> {
>> double d = std::log2(2.3456789f);
>> return 0;
>> }
>> results in
>> 'log2' is not a member of 'std'.
>> This happens with the system g++, which is i686-apple-darwin10-g++-4.2.1,
>> each of g++-4.0 g++-4.2 g++-mp-5 g++-mp-6, and with clang++-mp-3.4;
>> in each case, I am compiling as $CXX -std=c++11 prog.c
>> Apparently, there is some relatively recent turmoil about the C++ libs;
>> I don't know much c++ but find myself compiling some third party C++ code.
>> Am I missing something obvious?
>
> Well the Xcode-supplied g++s and clang would be using the system libstdc++, which doesn't support C++11, and std::log2 is a C++11 feature.
>
> The g++-mp variants should support it, but seemingly don't because of the bug that Ken mentioned, which should be fixed in GCC 7.
>
> Clang can support C++11 if you use -stdlib=libc++.

But on Snow Leopard, since it does not include libc++, you'd have to install it first (the libcxx port).

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'log2' is not a member of 'std'

Jan Stary
In reply to this post by Joshua Root-8
On Jul 03 03:28:30, [hidden email] wrote:

> > This is MacOSX 10.6.8 running various compilers provided by MacPorts.
> > Compiling the following C++ source
> >
> > #include <cmath>
> >
> > int main(void)
> > {
> > double d = std::log2(2.3456789f);
> > return 0;
> > }
> >
> > results in
> >
> > 'log2' is not a member of 'std'.
> >
> > This happens with the system g++, which is i686-apple-darwin10-g++-4.2.1,
> > each of g++-4.0 g++-4.2 g++-mp-5 g++-mp-6, and with clang++-mp-3.4;
> > in each case, I am compiling as $CXX -std=c++11 prog.c
> >
> > Apparently, there is some relatively recent turmoil about the C++ libs;
> > I don't know much c++ but find myself compiling some third party C++ code.
> > Am I missing something obvious?
>
> Well the Xcode-supplied g++s and clang would be using the system libstdc++,
> which doesn't support C++11, and std::log2 is a C++11 feature.

OK.

> The g++-mp variants should support it, but seemingly don't because of the
> bug that Ken mentioned, which should be fixed in GCC 7.

Yes, it compiles fine with g++-mp-7 as provided by the gcc7 port.
(Has the bug not been fixed in upstream GGC 5 and GCC 6,
or is it just the gcc5 and gcc6 port that is behind?)

> Clang can support C++11 if you use -stdlib=libc++.

Yes it does: clang++-mp-3.4 -stdlib=libc++ prog.cc

        Thank you

                Jan

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: 'log2' is not a member of 'std'

Jan Stary
On Jul 04 20:27:43, [hidden email] wrote:
> > Clang can support C++11 if you use -stdlib=libc++.
> Yes it does: clang++-mp-3.4 -stdlib=libc++ prog.cc

On Jul 02 13:02:44, [hidden email] wrote:
> But on Snow Leopard, since it does not include libc++, you'd have to install it first (the libcxx port).

The above works with clang-3.4 installed
and without libcxx installed.

        Jan

Loading...