473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

C++ headers

Hi. I'm trying to use the STL string class (new to STL), but not
having much luck. FYI, I'm using g++ on Linux 2.6. I included the
header as instructed:

#include <string>

But I get the error message:

error: `string' does not name a type

I looked at my '/usr/include' directory and found no file called
'string'. The file 'string.h' of course points to the basic string
functions.

Am I missing the STL headers?

If so why didn't the compiler yell at me that it couldn't find the
file?

Or did I jsut do something stupid?

Thanks in advance, guys.

Jul 28 '07 #1
10 2200
kramer31 wrote:
Hi. I'm trying to use the STL string class (new to STL), but not
having much luck. FYI, I'm using g++ on Linux 2.6. I included the
header as instructed:

#include <string>

But I get the error message:

error: `string' does not name a type

I looked at my '/usr/include' directory and found no file called
'string'. The file 'string.h' of course points to the basic string
functions.
What about /usr/include/c++/*/ ?
Am I missing the STL headers?
Probably not. In any case, the standard headers don't need to be actual
files.
If so why didn't the compiler yell at me that it couldn't find the
file?
It did find the file. Else it would have said something like 'string: No
such file or directory'.
Or did I jsut do something stupid?
My guess is that you used only 'string' instead of 'std::string' in your
code, but it's hard to say without any code.

--
rbh
Jul 28 '07 #2
What about /usr/include/c++/*/ ?

Non-existent.
>
Am I missing the STL headers?

Probably not. In any case, the standard headers don't need to be actual
files.
My guess is that you used only 'string' instead of 'std::string' in your
code, but it's hard to say without any code.
You are correct, sir! I did.

Still, I wouldn't mind finding out where that header is... (I guess
I'm just curious). I'm more used to c style headers where the actual
name of the file is in the #include directive. How do the
preprocessor know how to find <string>?

Anyway, thanks for your help.

Jul 28 '07 #3
kramer31 wrote:
>Hi. I'm trying to use the STL string class (new to STL), but not
having much luck. FYI, I'm using g++ on Linux 2.6. I included the
header as instructed:

#include <string>

But I get the error message:

error: `string' does not name a type
...
Try:

#include <string>
...
std::string some_string;

or

#include <string>
...
using namespace std;
...
string some_string;
Roberto Waltman

[ Please reply to the group,
return address is invalid ]
Jul 28 '07 #4
kramer31 wrote:
Still, I wouldn't mind finding out where that header is... (I guess
I'm just curious). I'm more used to c style headers where the actual
name of the file is in the #include directive. How do the
preprocessor know how to find <string>?
I assume the C++ standard, once again, doesn't specify exactly
how to do it, but in practice there is a file named "string" in the
include search path of the compiler. Filename extensions are not
mandatory in any filesystem.
Jul 28 '07 #5
tom
On Jul 29, 5:37 am, kramer31 <kramer.newsrea...@gmail.comwrote:
What about /usr/include/c++/*/ ?

Non-existent.
Am I missing the STL headers?
Probably not. In any case, the standard headers don't need to be actual
files.
My guess is that you used only 'string' instead of 'std::string' in your
code, but it's hard to say without any code.

You are correct, sir! I did.

Still, I wouldn't mind finding out where that header is... (I guess
I'm just curious). I'm more used to c style headers where the actual
name of the file is in the #include directive. How do the
preprocessor know how to find <string>?

Anyway, thanks for your help.
why don't you search the file by name, and verify whether the path is
in the search path of your compiler

Jul 29 '07 #6
Try

#include <bstring.h>

Thanks

Jul 29 '07 #7
why don't you search the file by name, and verify whether the path is
in the search path of your compiler
Actually, I did that ... well, I'm not sure what the search path of g+
+ is, but I searched /usr/include and there is no file called
'string'. There are lots of files like 'string.h' 'strings.h', but no
'string'.

A similar problem has come up as I'm trying to use the class hash_map
with #include <ext/hash_map>. The compiler finds its header, but I
can't.

Jul 29 '07 #8

kramer31 <kr***************@gmail.comwrote in message...
why don't you search the file by name, and verify whether the path is
in the search path of your compiler

Actually, I did that ... well, I'm not sure what the search path of g+
+ is, but I searched /usr/include and there is no file called
'string'. There are lots of files like 'string.h' 'strings.h', but no
'string'.
Then search from '/' (root).

If you don't find it, you may need to install another 'g++' package.

--
Bob R
POVrookie
Jul 29 '07 #9
On Jul 29, 11:58 am, kramer31 <kramer.newsrea...@gmail.comwrote:
why don't you search the file by name, and verify whether the path is
in the search path of your compiler

Actually, I did that ... well, I'm not sure what the search path of g+
+ is, but I searched /usr/include and there is no file called
'string'. There are lots of files like 'string.h' 'strings.h', but no
'string'.

A similar problem has come up as I'm trying to use the class hash_map
with #include <ext/hash_map>. The compiler finds its header, but I
can't.
In the future, you might want to consider a GCC or linux group, rather
than a C++ language group, for compiler-specific questions.

That said, on my linux system the file "string" and "deque" and all
the other standard includes exist in /usr/include/c++/4.1.2/ and were
provided by the package libstdc++6. The same files may or may not be
in the same place on your system.

Jul 29 '07 #10
On Jul 30, 6:58 am, kramer31 <kramer.newsrea...@gmail.comwrote:
Actually, I did that ... well, I'm not sure what the search path of g+
+ is, but I searched /usr/include and there is no file called
'string'. There are lots of files like 'string.h' 'strings.h', but no
'string'.

A similar problem has come up as I'm trying to use the class hash_map
with #include <ext/hash_map>. The compiler finds its header, but I
can't.
For best answers, ask in a g++ newsgroup. On my
system the C++ standard headers (note, the term
'STL' refers to a pre-standard library) are in
/usr/include/g++-3/

Jul 30 '07 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Philip Ronan | last post by:
OK, here's my 2p worth: === Q. Why am I getting the error message 'Headers already sent'? A. PHP produces this error message when you try to set a header for a web page after you have already...
3
by: sam | last post by:
Hello Group, Havent had luck posting it to microsoft.public.dotnet.framework.aspnet.datagridcontrol group. Excuse me for the cross posting. I have a datagrid which needs to be split into multiple...
71
by: Christopher Benson-Manica | last post by:
At what point was the .h dropped from the STL headers? I just had a discussion yesterday with my boss, who said he wanted .h on all the STL includes, despite me protesting that it was not...
1
by: stuart | last post by:
Hi, Can anybody tell me if it is possible to add your own headers through this class. The documenttion seems to be a bit ambiguous, for example the overview of the methods says Specifies the...
3
by: Jacky | last post by:
hi, I am trying to view the custom headers in an ASP.NET page. I am able to view all the standard headers using the method Request.Headers.Get(). But if i set a custom header using...
1
by: Ale News | last post by:
Hi to All.. I must add some custom headers HTTP and then i would to read them.. I used the AppendHeader Method to add my headers but when i try to read the headers i can't see my custom ones.....
2
by: fhtino | last post by:
Hello, I'm trying to create an email message with particular headers. A piece of code: SmtpClient smtp = new SmtpClient("192.168.x.y"); MailMessage msg = new MailMessage("from@xxxxxxx",...
5
by: Milos Prudek | last post by:
I perform a XML-RPC call by calling xmlrpclibBasicAuth which in turn calls xmlrpclib. This call of course sends a HTTP request with correct HTTP headers. The response is correctly parsed by...
4
by: sadieslc | last post by:
I'm working on a PHP script, and the info from the form shows up in the headers of the email that I receive, but it doesn't show up in the body of the email. Can you please help me figure out what...
6
Markus
by: Markus | last post by:
Things to discuss: Headers What are they? What does PHP have to do with headers? Why can they only be sent before any output? Common causes
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.