[Discussion-1] Simple C/C++ Perfometer: Reading file to string

9 views
Skip to first unread message

Alex Vinokur

unread,
Aug 7, 2005, 6:06:46 AM8/7/05
to C++ Perfometer Google Group
This is a reply to a message
http://groups.google.com/group/comp.lang.c++/msg/ea42d50075cc9a31 (in comp.lang.c++)

from the thread titled "What's wrong with std::ifstream::read()?"
http://groups.google.com/group/comp.lang.c++/browse_frm/thread/bac5e59508fd9c15



Steven T. Hatton wrote in http://groups.google.com/group/comp.lang.c++/msg/ea42d50075cc9a31
> Alex Vinokur wrote:
>
> >
> > Steven T. Hatton wrote:
> >> Alex Vinokur wrote:
> >>
> >> [...]
> >> > File file2str-1-0.cpp from
> >> > http://groups-beta.google.com/group/sources/msg/874798865afae595
> >
> >>
> >> I'm getting this on SuSE 9.3:
> >
> > [snip]
> >
> >>
> >> $ g++ -otext file2str-1-0.cpp
> >> file2str-1-0.cpp: In function `size_t get_filesize_via_lseek(const char*,
> >> bool)
> >> ':
> >> file2str-1-0.cpp:294: error: `O_BINARY' undeclared (first use this
> >> function) file2str-1-0.cpp:294: error: (Each undeclared identifier is
> >> reported only once for each function it appears in.)
> >>
> >> I tried hacking around it by replacing some of the code, but it looked
> >> like
> >> the hole was getting deeper. I'm not sure if, or where the macro is
> >> currently defined. From googling around, it looks like it used to come
> >> from <fcntl.h>.
> > [snip]
> >
> > O_BINARY is in fcntl.h (on UNIX).
>
> I'm not sure that is a current requirement for UNIX. SuSE's pretty good at
> getting the standards right. It's not there on my box, but there is a
> definition of O_BINARY in <kpathsea/c-fopen.h>. When I add that file to
> your program, it compiles, but when I run it, I get the following error:
>
> ================================================
> Simple C/C++ Perfometer : Reading file to string
> Version F2S-1.0
> ================================================
>
>
> -------------
> GNU gcc 3.3.5
> -------------
>
> YOUR COMMAND LINE : test 1024 1 1
>
> ### File size : 1024
> ### Number of runs : 1
> ### Number of tests : 1
> ### Number of repetitions : 1
> ### CLOCKS_PER_SEC : 1000000
>
>
>
> Run-1 of 1 : Started
> User defined file size = 1024
> Txt input file size = 1030
> Via fseek&ftell file size = 1024
> test: file2str-1-0.cpp:1966: void measure(long unsigned int): Assertion
> `infile_size2_txt == get_filesize_via_fseek_ftell ("z-txt.in", true)'
> failed.
> aborted
> --

[snip]

I have tested that with g++ 3.3.3 on Cygwin - no problem.

Result of getting file size can be OS-dependent.

To check file sizes in your case I would like to ask you to run program "Getting file size" from
http://groups.google.com/group/alt.sources/msg/41464ce8b75f8417 with g++ on your operating system
and send results as reply to this message.

-----
Alex Vinokur
email: alex DOT vinokur AT gmail DOT com
http://mathforum.org/library/view/10978.html
http://sourceforge.net/users/alexvn





Reply all
Reply to author
Forward
0 new messages