Hi,
Which system header file do I unclude in order to use the new string data
type?
KJ 8 8180
In article <3f********@news.iprimus.com.au>,
Newsnet Customer <ni********@iprimus.com.au> wrote: 2) I assume system header files provides implementations unlike user-defined header files, which are just interfaces.
No, the system header files are generally just interfaces also. An
exception may be the header files that declare template classes, because
many or most compilers don't support separate compilation of templates.
The implementations are usually in a compiled library file that your
compiler automatically links to your compiled code.
--
Jon Bell <jt*******@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
Newsnet Customer <ni********@iprimus.com.au> wrote in message
news:3f********@news.iprimus.com.au... 2) I assume system header files provides implementations unlike user-defined header files, which are just interfaces. That's not a question. As an assumption, it's incorrect. For a start, in the statement '#include <string>', the word 'string' is not a filename. The necessary declarations, etc., may or may not be stored in a file.
if string is not a filename then what file is it actually including in
this case? an object string?
The name of the *header* is <string>. The statement:
#include <string>
Is simply required to cause the compiler to provide
all declarations the language specifies it must, at
the scope where the #include directive appears.
A compiler is free to provide these delcarations any
way at all, e.g. via a file, 'hard coded' into the
compiler, or any other way at all. It's very common
for standard headers to be represented with files,
but not at all required.
-Mike
"Mike Wahler" <mk******@mkwahler.net> wrote in message news:5tq2b.2599 A compiler is free to provide these delcarations any way at all, e.g. via a file, 'hard coded' into the compiler, or any other way at all. It's very common for standard headers to be represented with files, but not at all required.
Not exactly right. The section header for #include
says "SOURCE FILE INCLUSION." The input units of C++ programs
are defined as SOURCE FILES in the standard. Of course, the C++
notion of source file may be different than what any particular
operating system's idea of a file is. As far as C++ is concerned
a source file is just a stream of implentation defined characters
that subsequently get processed into the source character set and then
into tokens.
Using a system that just uses a database of declarations does not meet
the C++ model (as those who were unfortunate enough to use IBM's attempt
at doing C++ that way found out).
"Newsnet Customer" <ni********@iprimus.com.au> wrote in message news:<3f********@news.iprimus.com.au>... 2) I assume system header files provides implementations unlike user-defined header files, which are just interfaces.
That's not a question. As an assumption, it's incorrect. For a start, in the statement '#include <string>', the word 'string' is not a filename. The necessary declarations, etc., may or may not be stored in a file.
if string is not a filename then what file is it actually including in this case? an object string?
Or a precompiled version that does exactly what the file would have done.
Or any other representation that makes the implementation behave as if
a file containg the definitions was included.
HTH,
--
Michiel Salters
Buster Copley <bu****@none.com> wrote in message news:<bi*********@news8.svr.pol.co.uk>... 0Newsnet Customer wrote:
,snip> 2) I assume system header files provides implementations unlike user-defined header files, which are just interfaces.
That said, in many cases there will be a header file called 'string'. And because separate compilation of templates is so tricky, the chances are most of the implementation will be available just from including the appropriate header. User header files may also include templates and inline functions.
<string> is special, because in 99,x% of the cases it is instantiated on
either char or wchar_t, so for these two cases an implementation may very
have a separation of interface and implementation. In addition, this can
be achieved in non-portable ways, because the <string> implementation
is a compiler-specific header.
Regards,
--
Michiel Salters
Newsnet Customer wrote: Right, so your saying that by including:
#include <string>
the compiler's preprocessor will include the contents of the <string> header file into the source, then compile the entire source file, and then link it with whatever file it neeeds (in this case, string.cpp). Is this what you mean?
It is very unlikely that this is what happens. Looking at it abstractly,
the implementation may not include a file called 'string'. It may not
have such a file at all. It's possible that it uses some magic to
replace the #include directive with the right stuff. It's also possible
that it doesn't do anything except set some kind of flag in the
compiler. "Header file" is not the right term, since it may or may not
be an actual file. The term is simply "header".
In most real implementations, 'string' is the name of a real file, and
the contents of that file are inserted into the source file at the point
of the #include directive. However, it's extremely unlikely that there
would be a 'string.cpp' file that the compiler would link in, for
several reasons.
First, compiler libraries are usually .lib or .obj files, and they
usually don't have one for every header. So it would be more likely to
have something like cppstd.lib that contains all or most of the standard
library (except for templates).
Second, std::string is a specialization of a template
(std::basic_string), and templates cannot be separately compiled in most
implementations. So 'string.cpp' wouldn't work. It's more likely that
the entire implementation of the basic_string template is in the
<string> header.
But basically you are asking hypothetical questions that don't have any
single answer and don't affect language usage anyway. So why bother
worrying about them?
-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting. > 2) I assume system header files provides implementations unlike user-defined > header files, which are just interfaces.
That's not a question. As an assumption, it's incorrect. For a start,
in the statement '#include <string>', the word 'string' is not a
filename. The necessary declarations, etc., may or may not be stored in a file.
if string is not a filename then what file is it actually including in
this case? an object string?
The name of the *header* is <string>. The statement:
#include <string>
Is simply required to cause the compiler to provide all declarations the language specifies it must, at the scope where the #include directive appears.
A compiler is free to provide these delcarations any way at all, e.g. via a file, 'hard coded' into the compiler, or any other way at all. It's very common for standard headers to be represented with files, but not at all required.
I asummed that if the header does not have an extension associated with it
then it's not a file, which leaves me thinking what <string> represents. I
don't think you have exactly told me that, but it appears that it could be
'hard-coded' into the compiler.
kdf
On Tue, 26 Aug 2003 16:24:03 +0930,
Newsnet Customer <ni********@iprimus.com.au> wrote: > > > 2) I assume system header files provides implementations unlike > user-defined > > > header files, which are just interfaces. > > > > That's not a question. As an assumption, it's incorrect. For a start, in > > the statement '#include <string>', the word 'string' is not a filename. > > The necessary declarations, etc., may or may not be stored in a file. > > > if string is not a filename then what file is it actually including in this > case? an object string?
The name of the *header* is <string>. The statement:
#include <string>
Is simply required to cause the compiler to provide all declarations the language specifies it must, at the scope where the #include directive appears.
A compiler is free to provide these delcarations any way at all, e.g. via a file, 'hard coded' into the compiler, or any other way at all. It's very common for standard headers to be represented with files, but not at all required.
I asummed that if the header does not have an extension associated with it then it's not a file, which leaves me thinking what <string> represents. I don't think you have exactly told me that, but it appears that it could be 'hard-coded' into the compiler.
Your assumption is incorrect. The header could be implemented as a file,
or it could just set a flag in the compiler, or whatever.
As a counter example to your assumption:
$ ls -l /gnu/usr/include/g++-3/string
-rw-rw-r-- 1 bin bin 238 Nov 18 1999 /gnu/usr/include/g++-3/string
That compiler/library combination implementation uses a file named 'string' to
perform #include <string>.
--
Sam Holden This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Carl Youngblood |
last post by:
I imagine this subject has probably been brought up numerous times.
Forgive me for bringing it up again. I was googling through old posts
on this newsgroup about it and found a good suggestion on...
|
by: Neil Schemenauer |
last post by:
The title is perhaps a little too grandiose but it's the best I
could think of. The change is really not large. Personally, I
would be happy enough if only %s was changed and the built-in was...
|
by: dpakpaul |
last post by:
Hi,
I have an XSD schema where I have attributes that are declared to
contain non string values such as integers etc. Take for example, this
declaration -
<xs:attribute name="IsThisTrue"...
|
by: jez123456 |
last post by:
Hi I'm attempting to pass a string into another string but I get an error
This code work ok
jro.CompactDatabase(@"Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=C:\Compact.mdb",...
|
by: tshad |
last post by:
The error I am getting is:
*******************************************************************
Exception Details: System.InvalidCastException: Cast from type 'DBNull' to
type 'String' is not...
|
by: MLH |
last post by:
120 MyString = "How many copies of each letter do you need?"
150 MyVariant = InputBox(MyString, "How Many?", "3")
If MyVariant = "2" Then MsgBox "MyVariant equals the string '2'"
If...
|
by: Barry |
last post by:
Hello,
In VS2003, I tried using an enum and setting it into a field in a
datarow. It seems as if the datatype of the field in the row
determined what went into the field. If the datatype was...
|
by: zoltan |
last post by:
Hi,
The scenario is like this :
struct ns_rr {
const u_char* rdata;
};
The rdata field contains some fields such as :
|
by: Scott M. |
last post by:
Ok, this is driving me nuts...
I am using VS.NET 2003 and trying to take an item out of a row in a
loosely-typed dataset and place it in a label as a currency. As it is now,
I am getting my...
|
by: jacob navia |
last post by:
Abstract:
Continuing the discussion about abstract data types, in this
discussion group, a string collection data type is presented,
patterned after the collection in C# and similar languages...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
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,...
|
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...
|
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,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
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...
| |