Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #106145
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Keith Thompson <kst-u@mib.org> |
| Newsgroups | comp.lang.c |
| Subject | Re: More problems with lcc-win |
| Date | Wed, 15 Mar 2017 09:52:58 -0700 |
| Organization | None to speak of |
| Lines | 90 |
| Message-ID | <lny3w6h47p.fsf@kst-u.example.com> (permalink) |
| References | <20d9275b-7502-4ad0-b343-5cecf8c6ea90@googlegroups.com> <oab4pn$bg2$1@dont-email.me> <lnd1diimts.fsf@kst-u.example.com> <oabng1$9mg$1@dont-email.me> <oabom4$5ss$1@dont-email.me> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| Injection-Info | mx02.eternal-september.org; posting-host="1d05d6df43238c69e85c0f471787c307"; logging-data="15294"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/eCLMkLj5scg5okcTA+W5F" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) |
| Cancel-Lock | sha1:ThB3H3an3/MuoeREiQ/CQNIosas= sha1:+LqfEVIa7oT5jGEn+fQ+Phuz+Ro= |
| Xref | csiph.com comp.lang.c:106145 |
Show key headers only | View raw
David Brown <david.brown@hesbynett.no> writes:
> On 15/03/17 16:46, jacobnavia wrote:
>> Le 15/03/2017 à 16:25, Keith Thompson a écrit :
>>> jacobnavia <jacob@jacob.remcomp.fr> writes:
>>> [...]
>>>> As I told you before, fseeki64 doesn't exist in the 64 bit version and
>>>> has been replaced by fseek now, that returns a long long
>>>
>>> Do you mean long rather than long long?
>>>
>>> [...]
>>>
>>
>> No, I was speaking of the second argument of fseek actually.
>> The standard mandates long but I can't use that since it is 32 bits.
>> So I changed the function to use a long long and everything is OK, no
>> need for fseeki64
>
> The standard says "int" for the return type of fseek:
>
> int fseek(FILE *stream, long int offset, int whence);
>
> The return value is either 0 for success, or non-zero for failure.
Both jacob and I managed to confuse fseek's second parameter with its
return type. The return type is not an isse; it's just an int that
tells you whether it succeeded or failed. But the standard makes the
second parameter of fseek, as well as the return type of ftell, long.
This is IMHO a flaw in the standard. I could argue that 64-bit Windows
*should* have made long 64 bits, as 64-bit Linux does, but making it 32
bits is perfectly valid.
In C89/C90, long was the only reasonable choice, since it was the
longest signed integer type. With the addition of long long in C99,
(and the increasing commonality of files bigger than 2 gigabytes), the
use of long for file offsets became a problem.
IMHO C99 *should* have defined a new typedef for the signed integer type
used by fseek() and ftell(). (Using size_t might have been another
alternative, and it would work for 64-bit Windows, but files can be
bigger than any supported objects, so size_t isn't really the right
type.)
[...]
> What does MSVC do in this case? I would expect that the best choice is
> to copy the behaviour of the nearest Windows has to a standard compiler.
https://msdn.microsoft.com/en-us/library/75yw9bf3.aspx
It defines fseek() as the Standard does, with a long argument, and also
provides _fseeki64 which uses __int64 (int64_t would have made more
sense, but it might not have been supported when _fseeki64 was
introduced). Given that long isn't wide enough to use as a file offset,
I think that's the best solution -- except that I'd suggest defining a
typedef for the offset type.
fgetpos() and fsetpos() avoid this problem by using type fpos_t, which
isn't necessarily an integer type (it's a struct in glibc), but those
functions are less flexible. In particular, you can't seek to a
relative position, only to a position from an earlier call to fgetpos().
I would suggest:
1. For current implementations with 64-bit long, just define fseek()
and ftell() as the standard specifies.
2. For current implementations with 32-bit long, or more generally
where long isn't wide enough to use as a file offset, define
fseek() and ftell() as the standard specifies and provide
supplemental functions that use a wider integer type.
3. In a future standard, change fseek() and ftell() to use a
wider type. I suggest using a typedef, but long long might also
be reasonable. (long long must be at least 64 bits; 8 exabytes
is *probably* enough for file offsets for the foreseeable future.)
Defining fseek() and ftell() to use long long is clearly
non-conforming in C90, C99, and C11. Each implementer has to
decide how much of a problem that is. (In the case of lcc-win,
I'm not a user, so I don't get a vote.) It's unlikely to break any
non-contrived user code, since implicit conversions will quietly
handle most inconsistencies.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
More problems with lcc-win mertesthomas@gmail.com - 2017-03-15 00:29 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 11:27 +0100
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-15 13:18 +0000
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 15:22 +0100
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 08:26 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 08:25 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 16:46 +0100
Re: More problems with lcc-win David Brown <david.brown@hesbynett.no> - 2017-03-15 17:07 +0100
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 09:52 -0700
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-15 16:57 +0000
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 10:11 -0700
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-15 18:17 +0000
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-15 17:21 +0000
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-15 18:42 +0100
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-15 18:20 +0000
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-15 18:59 +0000
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-15 18:20 +0000
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-15 19:39 +0100
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 12:44 -0700
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-15 20:19 +0000
Re: More problems with lcc-win David Brown <david.brown@hesbynett.no> - 2017-03-16 10:03 +0100
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-16 11:15 +0000
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-16 11:32 +0000
Re: More problems with lcc-win David Brown <david.brown@hesbynett.no> - 2017-03-16 13:41 +0100
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-16 08:52 +0100
Re: More problems with lcc-win David Brown <david.brown@hesbynett.no> - 2017-03-16 09:57 +0100
Re: More problems with lcc-win antispam@math.uni.wroc.pl - 2017-03-16 13:53 +0000
Re: More problems with lcc-win jm.bourguet@gmail.com - 2017-03-16 07:14 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-16 08:59 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 12:43 -0700
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-15 20:39 +0000
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 23:56 +0100
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-15 16:33 +0000
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 17:47 +0100
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 10:04 -0700
Re: More problems with lcc-win jacob navia <jacob@jacob.remcomp.fr> - 2017-03-16 00:52 +0100
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 18:02 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 18:23 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-17 13:45 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-18 00:23 +0100
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-18 00:29 +0100
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-18 00:31 +0100
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-17 17:01 -0700
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-20 16:41 +0000
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-20 18:32 +0100
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-20 18:18 +0000
Re: More problems with lcc-win bart4858@gmail.com - 2017-03-20 12:31 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-20 21:05 +0100
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-20 20:45 +0000
Re: More problems with lcc-win Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-20 20:18 +0000
Re: More problems with lcc-win David Brown <david.brown@hesbynett.no> - 2017-03-21 09:56 +0100
Re: More problems with lcc-win Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-03-21 21:08 +0000
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-21 22:19 +0100
Re: More problems with lcc-win Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-03-22 06:29 +0000
Re: More problems with lcc-win supercat@casperkitty.com - 2017-03-21 16:12 -0700
Re: More problems with lcc-win gordonb.s97bd@burditt.org (Gordon Burditt) - 2017-03-24 01:13 -0500
Re: More problems with lcc-win supercat@casperkitty.com - 2017-03-24 08:16 -0700
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-26 03:18 -0700
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-26 12:35 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-29 05:17 -0700
Re: More problems with lcc-win supercat@casperkitty.com - 2017-03-26 14:04 -0700
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-29 05:48 -0700
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-21 23:21 +0000
Re: More problems with lcc-win Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-03-22 06:18 +0000
Re: More problems with lcc-win gordonb.1neik@burditt.org (Gordon Burditt) - 2017-03-21 18:45 -0500
Re: More problems with lcc-win jm.bourguet@gmail.com - 2017-03-22 01:02 -0700
Re: More problems with lcc-win David Brown <david.brown@hesbynett.no> - 2017-03-22 10:35 +0100
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-22 13:21 +0000
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-22 14:08 +0000
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-22 15:37 +0000
Re: More problems with lcc-win Gareth Owen <gwowen@gmail.com> - 2017-03-22 21:09 +0000
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-21 13:09 +0000
Re: More problems with lcc-win Jorgen Grahn <grahn+nntp@snipabacken.se> - 2017-03-21 21:15 +0000
Re: More problems with lcc-win Ian Collins <ian-news@hotmail.com> - 2017-03-18 12:44 +1300
Re: More problems with lcc-win jameskuyper@verizon.net - 2017-03-17 16:59 -0700
Re: charsets Noob <root@127.0.0.1> - 2017-03-18 18:30 +0100
Re: More problems with lcc-win David Brown <david.brown@hesbynett.no> - 2017-03-16 10:18 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-15 15:06 -0700
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-15 22:23 +0000
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-15 15:43 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 23:53 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-16 08:35 -0700
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-15 23:13 +0000
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-16 06:28 -0700
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-16 16:56 +0000
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-16 14:53 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 16:18 -0700
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-16 18:03 +0000
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-16 19:29 +0100
Re: More problems with lcc-win Ben Bacarisse <ben.usenet@bsb.me.uk> - 2017-03-16 21:38 +0000
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-17 08:58 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-17 09:45 -0700
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-17 10:33 -0700
Re: More problems with lcc-win "James R. Kuyper" <jameskuyper@verizon.net> - 2017-03-17 14:20 -0400
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-17 20:18 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-18 00:44 -0700
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-18 13:31 +0000
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-18 15:54 -0700
Re: More problems with lcc-win scott@slp53.sl.home (Scott Lurndal) - 2017-03-20 13:27 +0000
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-18 15:15 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-18 11:39 -0700
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-18 20:11 +0100
Re: More problems with lcc-win BartC <bc@freeuk.com> - 2017-03-18 19:45 +0000
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-20 00:35 -0700
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-18 14:22 -0700
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-18 22:46 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-18 16:12 -0700
Re: More problems with lcc-win supercat@casperkitty.com - 2017-03-18 18:01 -0700
Re: More problems with lcc-win GOTHIER Nathan <nathan.gothier@gmail.com> - 2017-03-19 03:21 +0100
Re: More problems with lcc-win Ian Collins <ian-news@hotmail.com> - 2017-03-19 15:32 +1300
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-19 02:17 -0700
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-15 14:25 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 23:49 +0100
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 11:28 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-15 14:35 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 23:44 +0100
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 13:06 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-15 14:43 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 23:43 +0100
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 13:19 +0100
Re: More problems with lcc-win mertesthomas@gmail.com - 2017-03-15 14:50 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 08:24 -0700
Re: More problems with lcc-win jacobnavia <jacob@jacob.remcomp.fr> - 2017-03-15 16:47 +0100
Re: More problems with lcc-win jameskuyper@verizon.net - 2017-03-15 09:04 -0700
Re: More problems with lcc-win Keith Thompson <kst-u@mib.org> - 2017-03-15 09:15 -0700
Re: More problems with lcc-win gazelle@shell.xmission.com (Kenny McCormack) - 2017-03-15 19:59 +0000
Re: More problems with lcc-win Richard Heathfield <rjh@cpax.org.uk> - 2017-03-15 16:32 +0000
csiph-web