Bug 1469 – "alias int fpos_t" in std.c.stdio is wrong on Darwin
Status
RESOLVED
Resolution
FIXED
Severity
blocker
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
PowerPC
OS
Mac OS X
Creation time
2007-09-02T16:07:00Z
Last change time
2015-06-09T05:15:13Z
Assigned to
bugzilla
Creator
u.singer
Comments
Comment #0 by u.singer — 2007-09-02T16:07:42Z
Hi,
I am using the D compiler on Mac OS X 10.4 ("gdc-0.24-mac-10.4.dmg" from sourceforge.net).
In /usr/include/d/4.0.1/std/c/stdio.d, I found:
alias int fpos_t;
, which is wrong for Darwin. See/usr/include/stdio.h & /usr/include/sys/_types.h on that platform. A better coding would presumably be:
version (darwin)
alias long fpos_t; // Darwin wants 64 bits.
else
alias int fpos_t;
Thanks!
Comment #1 by braddr — 2007-09-02T16:22:34Z
Moving to the right product, dgcc aka gdc
Comment #2 by afb — 2007-09-03T01:57:07Z
Darwin uses "long" for fpos_t in C too, on 32-bit Mac OS X at least.
But when D starts supporting 64-bit, it does need to be changed...
Comment #3 by u.singer — 2007-09-04T13:13:12Z
(In reply to comment #2)
> Darwin uses "long" for fpos_t in C too, on 32-bit Mac OS X at least.
> [...]
>
Well it did - "did" from my point of view :-) . Here are the relevant lines from my headers (gcc 4.0.1):
/usr/include/stdio.h:
#if !defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI__)
typedef __darwin_off_t fpos_t;
#else
typedef __int64_t fpos_t;
#endif
/usr/include/sys/_types.h:
typedef __int64_t __darwin_off_t; /* [???] Used for file sizes */
Admittedly, my current CPU is a PowerPC G5 (ppc970), which is a 64-bit processor. The OS version is Mac OS X 10.4.10 (Darwin 8.10.0), but the 64-bit definition was there from 10.4.0 (Darwin 8.0.0) on. Opposed to this, size_t & sizeof(void*) are (normally) still 32-bit and standard OS ABIs depend on that. I have no idea yet what this looks like on the current Intel-CPU Macs...
I saw that there already are CPU-specific tests like "version (BigEndian)" & "version (LittleEndian)". Maybe a similar OS-independent thing to test 64-bittedness, combined with the OS, would address the problem better than a pure OS dependency.
Comment #4 by afb — 2007-09-04T14:01:19Z
Oh, it definitely should be changed eventually just like the others have been. Just that I hadn't run into the issue yet, since 64-bit support is rather new.
Usually things that vary in size (like fpos_t) would be autoconfigured and put into configunix.d with the rest of the platform-specific stuff... (gcc.config)
Comment #5 by dvdfrdmn — 2007-09-07T20:08:37Z
Fixed in svn rev 1469 / release 0.25.
Note that fpos_t is still wrong for Linux and possible other system.