Topic: no create missing
Author: grasbon@jupiter.cs.uni-dortmund.de (Reimar Grasbon)
Date: Mon, 25 Nov 2002 19:19:05 +0000 (UTC) Raw View
After introducing (compile) the new GNU-Compiler
Version 3.2.1 for our Systems (Linux ans Solaris),
I get many warnings and errors. So e.g. for the
source code line:
fileObj.open(fileName, ios::in|ios::nocreate|ios::binary);
the compiler reacts with:
'nocreate' is not a member of type 'std::basic_ios<char, ...
I tried to identify, where the type (enum) 'nocreate' is
defined but then I realized, that in the "include-files"
which comes along with the compiler, this enum is
missing.
Did I something wrong? I cannot believe, that such
important definitions had been removed in the newer
ANSI-Version.
... Reimar
BTW: Is there a deeper sense for skipping the ".h"
extensions for headers? I think there will be more
confusions than clearer codes!?
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: dietmar_kuehl@yahoo.com (Dietmar Kuehl)
Date: Tue, 26 Nov 2002 03:52:54 +0000 (UTC) Raw View
Reimar Grasbon wrote:
> fileObj.open(fileName, ios::in|ios::nocreate|ios::binary);
Which additional functionality do you expect from the 'nocreate' flag?
How is the above call different from the follwoing?
fileObj.open(fileName, ios::in | ios::binary);
Hint: The above open mode is equivalent to the stdio mode "rb" (see
section 27.8.1.3 paragraph 2) and this is specified as "open binary file
for reading" in 7.19.5.3 pargagraph 3 of the C standard (well, the C99
standard while the C++ standard refers to the C90 standard but I doubt
that there is a difference). Since other open modes explicitly state
that they would create a file if needed, it is implicit that no file is
to be created if it does not exist.
--
<mailto:dietmar_kuehl@yahoo.com> <http://www.dietmar-kuehl.de/>
Phaidros eaSE - Easy Software Engineering: <http://www.phaidros.com/>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: grasbon@jupiter.cs.uni-dortmund.de (Reimar Grasbon)
Date: Tue, 26 Nov 2002 15:46:05 +0000 (UTC) Raw View
Dietmar Kuehl schrieb:
>Reimar Grasbon wrote:
>
>
>>fileObj.open(fileName, ios::in|ios::nocreate|ios::binary);
>>
>>
>
>Which additional functionality do you expect from the 'nocreate' flag?
>How is the above call different from the follwoing?
>
> fileObj.open(fileName, ios::in | ios::binary);
>
... avoiding file creation in the case of no existance. I know, that
it doesn't make sence to create an empty file for reading, but
the documentation of "ifstream::open" in Visual C++ 6.0 gives
the enum "ios::nocreate" as possible value for the second
parameter "nMode". And the GNU-includes supports
(resp. supported) this feature also.
I can not refer to the ANSI-Standard because I don't have the
papers. So there was no reason to believe, that creating a
file for reading will not take place.
Thanx for the hint.
... Reimar
<http://dict.tu-chemnitz.de/dings.cgi?o=3001&service=en-de&query=consideration>
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]
Author: a9804814@unet.univie.ac.at (Thomas Mang)
Date: Tue, 26 Nov 2002 15:47:13 +0000 (UTC) Raw View
Reimar Grasbon schrieb:
> After introducing (compile) the new GNU-Compiler
> Version 3.2.1 for our Systems (Linux ans Solaris),
> I get many warnings and errors. So e.g. for the
> source code line:
>
> fileObj.open(fileName, ios::in|ios::nocreate|ios::binary);
>
> the compiler reacts with:
>
> 'nocreate' is not a member of type 'std::basic_ios<char, ...
>
> I tried to identify, where the type (enum) 'nocreate' is
> defined but then I realized, that in the "include-files"
> which comes along with the compiler, this enum is
> missing.
> Did I something wrong? I cannot believe, that such
> important definitions had been removed in the newer
> ANSI-Version.
'nocreate' is not defined in the standard anymore, so implementations might
provide it, but no requirement. (This, if supplied, not portable in standard
C++ - sense).
( I leave it up to others to consider this important or not).
>
>
> BTW: Is there a deeper sense for skipping the ".h"
> extensions for headers? I think there will be more
> confusions than clearer codes!?
The deeper sense is that the file without the ".h" - exists :-)
Take a look at 17.1.4.2 and D.5 for more info.
( The C++ - header files without the suffix might be provided, mainly for
backward compatibility, but it is not required. So basically the same as for
nocreate holds.
Sometimes, however, you have to use the .h - suffix, because
curent-compatibility is not provided yet.....)
I think your GNU-implementation will eat this code:
#include <utility>
but not eat this:
#include <utility.h>
Just try it out, I am not 100% sure.
cheers,
Thomas
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ]