This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++: compiling with iostream header: error: unknown type name 'char_traits'


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.

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++.

Thanks
Nobin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]