How can I enable _GLIBCXX_USE_C99 on Solaris 8 SPARC? - c++

I've built gcc 4.6.1 for Solaris 8 sparc. I'm compiling some code that uses boost::lexical_cast (boost 1.48) and I get this error:
boost/math/special_functions/sign.hpp: In function 'int boost::math::detail::signbit_impl(T, const boost::math::detail::native_tag&)'
error: 'signbit' is not a member of 'std'
(Also similar errors for fpclassify, isfinite, isnormal, isinf, isnan)
I looked at the cmath header and it defines std::signbit conditionally depending on whether _GLIBCXX_USE_C99_MATH is defined. I ran cpp -dM and I see that _GLIBCXX_USE_C99_MATH is not defined. Is there a way to enable the C99 support? Do I have to rebuild libc or is this platform just too old? I'm out of my element so any guidance on getting this working would be great.

Your platform C library is likely too old to support the C99 FP library additions.
From the Sun Studio 12 User's Guide:
Note - Though the compiler defaults to supporting the features of C99 listed
below, standard headers provided by the Solaris software in /usr/include do
not yet conform with the 1999 ISO/IEC C standard. If error messages are
encountered, try using -xc99=none to obtain the 1990 ISO/IEC C standard
behavior for these headers.

Related

Library support for the ISO c++ 2011 standard in omnet

I am using OMNET 4.4. When OMNET compiles it says that
this file requires compiler and library support for the ISO c++ 2011 standard. This support is currently experimental and must be enabled with -std=c++11 or -gnu=c++11 compiler options.
Also following error appears:
/veins/modules/application/traci/TraCITestApp.h:78:36: warning: non-static data member initializers only available with -std=c++11 or -std=gnu++11 [enabled by default]
I am using windows 10 and I could not find solution to it in internet .
Can anyone help me with some information ?
First, this warning is not coming up from the build of OMNeT++, but from the build of Veins. It is not the same. OMNeT++ 4.4 builds without C++11 support fine, but it seems that recent versions of Veins may need it. However again, this is a warning. OMNeT++ 4.6 and later can be configured with the -std=c++11.
You may need to update your compiler, too as any recent compiler fully supports c++11 since at least 3 years.

Many questions about the various C++ compilers available to me on OS X

I am having trouble understanding the different compilers that are available to me.
I mainly use Xcode for writing and compiling, and in Xcode's preferences, there are all of these options for C++ compilation:
C++ Language Dialect:
C++98[-std=c++98] through C++14[-std=c++14]
GNU++98[-std=gnu++98] through GNU++14[-std=gnu++14]
C++ Standard Library:
libstdc++ (GNU C++ standard library)
libc++ (LLVM C++ standard library with C++11 support)
Can someone explain what exactly all of that ^ is?
I understand that (and correct me if I'm wrong), that apple no longer distributes GCC with Xcode and use Clang instead?
If that were the case, then why does Xcode have the option for GNU C++ standard library? Doesn't GNU make GCC?
What compiler is invoked when I run C++ code in my local terminal with g++ filename.cpp?
Is there any way to make sure that this g++ "compiler" is up to date?
What's the difference between compiling with g++ in the terminal and using Xcode?
Also, what would be the difference if I tried running C++ programs with Clang?
My class requires us to test our programs on the department's server's compiler via ssh from my terminal. The server is a Unix machine and I know that its compiler is GNU's GCC compiler and we also access it using g++. Does this mean that the local g++ in my terminal is also GCC?
edit: Grammar
1.
C++ language dialect
C++98[-std=c++98] through C++14[-std=c++14]
GNU++98[-std=gnu++98] through GNU++14[-std=gnu++14]
The C++ language has evolved over time. These are the various versions of the language that are available to you. If you have to be compatible with something old, you might be forced to use an old one. Otherwise you'd probably want ot use the newest available, which is c++14 in the list above. 14 stands for 2014, 98 for 1998 - it is supposed to represent the year that version of the standard was blessed.
In addition to standard C++ there are non-standard extensions. Gnu is a compiler "manufacturer", the "GNU" above is the non-stanadard extensions as specified by GNU for a particular documented version.
C++ Standard Library:
libstdc++ (GNU C++ standard library)
libc++ (LLVM C++ standard library with C++11 support)
In addition to the base language, the standard library is also a part of the standard. These are two different implementations of the standard library. The first is by GNU, the second by llvm. llvm are a different compiler manufacturer.
On osx you'd probably use libc++ as I believe the llvm compiler (clang++) is now standard there. The llvm compiler will support the gnu extensions if you need them. You probably don't. Just use the latest version of whatever is default.
Yes
two different pieces, the compiler and the standard library. You can use clang++ with libstd++
g++ -v will tell you
not really. Update xcode to the newest or start looking at homebrew or ports to get the latest and greatest they package of whatever compiler you like.
Probably the same compiler, you can set it either to point at any compiler you have installed. So what each points at is your choice.
both g++ and clang++ are standards compliant. You're unlikely to notice much difference. They will complile the same source files into equivalent binaries.
run g++ -v in any terminal to see exactly what it is.

No _fdopen on Linux and gcc

I'm calling fdopen. On Windows, using Visual C++ 2010, when I call it I get a warning saying
Warning 1 warning C4996: 'fdopen': The POSIX name for this item is deprecated. Instead, use the ISO C++ conformant name: _fdopen.
On Linux (g++ 4.8.2) it works.
When I switch to _fdopen, Visual C++ stops complaining, but g++ can't find it. Since g++ does find fdopen, I don't think it's the issue described here. And anyway, I'm not specifying -std=c++11 .
Should I use _fdopen? Should I use fdopen and ignore the warning?
fdopen is not part of the C++ standard, but POSIX. While pretty much every C++ compiler maintainer wants to fulfill the C++ standard, there is little consensus if and how POSIX is supported.
Essentially, fdopen falls into the same category as any completely platform specific function; it´s just different on different systems. If the warning bugs you, you can use some preprocessor stuff to use one part of the code in Windows and another in Linux, eg. in your own fdopen-wrapper.
About the message that _fdopen is ISO C++ conformant: The C++ standard says something like everything with _ in the beginning is compiler-specific. So yes, in that point it´s conformant.

can not include std array in dev c++ 5.9

I wanted to include array in DEv C++ 5.9 but it gave an error:
32 2 c:\program files (x86)\dev-cpp\mingw64\lib\gcc\x86_64-w64-mingw32\4.8.1\include\c++\bits\c++0x_warning.h [Error] #error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
Is this because of the version of DEV-C++ that I am using or my computer IOS? I used other versions of DEV C++ but since I have a windows 8 on my computer, they did not work on that and I needed to use this version of DEV C++. Any help is appreciated.
Thanks
The error message tells you exactly how to fix the error.
#error This file requires compiler and library support for the ISO C++ 2011 standard. This support is currently experimental, and must be
enabled with the -std=c++11 or -std=gnu++11 compiler options
Read your IDE documentation to figure out how to do this or refer to this image.
http://www.cplusplus.com/doc/tutorial/introduction/devcpp/devcpp2.png
In DEV C++ , tools << set the compiler to debug/release << Setting << Code Generation << Language standard(-std) << ISO C++11 or GCC C++11 (whatever you use) << complie your code of std::array using debug/release whatever you used earlier..
Is this because of the version of DEV-C++ that I am using or my
computer IOS?
No, it depends on the C++ compiler version.
As the error says:
This file requires compiler and library support for the ISO C++ 2011
standard.

xcode 5.1.1 complaining: ISO C++11 does not allow access declarations

I have a project that builds and runs fine on Xcode 4.6.3.
But it does not on Xcode 5.1.1.
This is the unique error I get, hundred times.
"ISO C++11 does not allow access declarations; use using declarations instead".
Basically it wants me to go from:
typedef Something<MType>::Index Index;
Something<MType>::N;
to
typedef Something<MType>::Index Index;
using Something<MType>::N;
Why is it?
If I "solve it" as Xcode says, the final app behaves randomly.
Is it possible to build this project on Xcode 5.1.1 as if it were 4.6.3? (in other words: changing the project settings, but keeping the code intact)
AFAIS, the C++ flags have the same value for both Xcode versions.
C Language Dialect = GNU99 [-std=gnu99]
C++ Language Dialect = GNU++11 [-std=gnu++11]
C++ standard library = libc++ (LLVM C++ standard library with C++11 support)
It looks like a deliberate change to the compiler:
http://llvm.org/viewvc/llvm-project?view=revision&revision=183882
The standards body says: "Access declarations were deprecated in the 1998 standard and have no benefits over using-declarations. They should be removed in C++0x."
And I can't find anyway of reverting to an older (non-standard compliant) C++11 behaviour. I was half expecting this to work:
clang -std=c++0x
But, it doesn't. You get the same error.
Including using looks like the right fix. I've just done some testing here and it does what it says on the tin.
Probably not what you want to hear, but I think you should look into why the code behaves randomly when you use the using directive.