On Sun, Jun 20, 2010 at 11:03 AM, Nobin Mathew <nobin.mathew@xxxxxxxxx> wrote: > Hi, > > I am having a problem with libstdc++ headers, I am having a simple > application which uses iostream library. In order to parse it I am > using clang library application. > > For that I am getting an error like this > > In file included from /home/nmathew/Desktop/algorithms/array.cpp:1: > In file included from /usr/include/c++/4.4.3/iostream:39: > In file included from /usr/include/c++/4.4.3/ostream:39: > In file included from /usr/include/c++/4.4.3/ios:38: > In file included from /usr/include/c++/4.4.3/iosfwd:40: > /usr/include/c++/4.4.3/bits/stringfwd.h:49:48: error: unknown type > name 'char_traits' > > > If I use g++ it compiles properly. > > > My include search directories are below: > > #include "..." search starts here: > #include <...> search starts here: > /usr/include/linux > /usr/lib/gcc/i686-redhat-linux/4.4.3/include > /usr/include/c++/4.4.3 > /usr/include/c++/4.4.3/backward > /usr/include/c++/4.4.3/i686-redhat-linux > /usr/local/include > /usr/include > End of search list. and char_traits.h is in /usr/include/c++/4.4.3/bits/ > > When I looked at the header source, this is the order of inclusion > iostream->ostream->ios->iosfwd > > iosfwd uses uses char_traits but bits/char_traits.h is included after > iosfwd in ios header > > From /usr/include/c++/4.4.3/ios > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > #ifndef _GLIBCXX_IOS > #define _GLIBCXX_IOS 1 > > #pragma GCC system_header > > #include <iosfwd> > #include <exception> // For ios_base::failure > #include <bits/char_traits.h> // For char_traits, streamoff, streamsize, fpos > #include <bits/localefwd.h> // For class locale > #include <bits/ios_base.h> // For ios_base declarations. > #include <streambuf> > #include <bits/basic_ios.h> > > #endif /* _GLIBCXX_IOS */ > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > From /usr/include/c++/4.4.3/iosfwd > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > #ifndef _GLIBCXX_IOSFWD > #define _GLIBCXX_IOSFWD 1 > > #pragma GCC system_header > > #include <bits/c++config.h> > #include <bits/stringfwd.h> // For string forward declarations. > #include <bits/postypes.h> > > _GLIBCXX_BEGIN_NAMESPACE(std) > > template<typename _CharT, typename _Traits = char_traits<_CharT> > > class basic_ios; > > template<typename _CharT, typename _Traits = char_traits<_CharT> > > class basic_streambuf; > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > How this works and what is the use of bits/c++config.h file. > > Please help even if this is a dump question, I am new to the land of c++. I am using Fedora 12, where [nmathew@Alchemist cppscope]$ gcc -v Using built-in specs. Target: i686-redhat-linux Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-bootstrap --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --enable-plugin --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre --enable-libgcj-multifile --enable-java-maintainer-mode --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib --with-ppl --with-cloog --with-tune=generic --with-arch=i686 --build=i686-redhat-linux Thread model: posix gcc version 4.4.3 20100127 (Red Hat 4.4.3-4) (GCC) > > Thanks > Nobin >