because ftruncate() is declared as
int ftruncate(int, off_t)
int ftruncate(int, _off_t)
(at the bottom of the unistd.h)
Hmm. According to MSDN:
*both* off_t and _off_t should be defined as standard data types, (and both serving the same purpose). I'm wondering if the real bug here is not in sys/types.h? Perhaps off_t should be type defined, irrespective of _NO_OLDNAMES.
Since I cross-posted this issue to the mingw-w64 tracker, here is a link:
So, now you have polluted this report with information you have abstracted from an illegitimate source, (MS proprietary headers), which we *cannot* use as a basis for fixing this. Neither can we use any further information which you provide, related to this topic. Thanks a bunch!
In any case, what is said in the comment in that snippet is misleading; the standard type name, *required* by *POSIX*, (this type is not required by ANSI C99 at all, AFAICT), is `off_t', *not* `_off_t'.
The only solutions which I will now consider to be acceptable, is the one I'd already suggested, prior to your pollution of the ticket, viz. removal of the _NO_OLDNAMES guard around the typedef of `off_t', or your original suggestion that unistd.h refer only to `_off_t'. Of these two, I prefer the POSIX conforming choice; (POSIX *requires* sys/types.h to define `off_t').
To qualify that further, (since POSIX specific names normally *are* guarded by _NO_OLDNAMES, in MinGW headers), removal of the guard in this case, is required to conform to the MSDN documentation, (which we *can* use as a legitimate reference source), irrespective of what Microsoft actually put in their own headers, (which we have no legitimate way to determine); we are obliged to implement it as *documented*, (on MSDN). POSIX requires sys/types.h to define `off_t'; so does MSDN.
As I answered before seen these header parts, I think this would be a valid way too:
"I think the best would be to change the type just for the
case, when NO_OLDNAMES is defined. Otherwise we would get in conflict with
POSIX. Eg. gcc in sys.protos.h declares it by using off_t. This would lead
Do you think this is ok?"
Guys, sorry for "polluting" this report :-)
Thanks for the apology; unfortunately, the damage has been done.
I think the best, and cleanest solution, is just to remove the _NO_OLDNAMES guard from around the `off_t' typedef in sys/types.h, and to leave unistd.h as is. That way, we don't introduce any conflict with POSIX, or GCC's usage.
In fact, _NO_OLDNAMES was never the correct guard here. Microsoft have actually done the right thing, by guarding on their equivalent of __STRICT_ANSI__, since ANSI C99 doesn't define `off_t'. Unfortunately, the poisoning of this ticket by actual Microsoft source means that we cannot now hide the definition for the strict ANSI case; to progress that, we would have to wait until someone with no association to this ticket raises a new bug report, (after sufficient time for the details of this discussion to have been forgotten).
Well, now I'll try my best not to "poison" more.
The thing is that now Microsoft guards *EVERYTHING* with a __STRICT_ANSI__-like thing, _NO_OLDNAMES is in fact a Mingw-specific macro now. So if you want to be really compatible with Microsoft, you should replace _NO_OLDNAMES with __STRICT_ANSI__ *everywhere*. But this is a subject to another discussion and another ticket. For now Mingw uses _NO_OLDNAMES for this purpose. Therefore, for consistency with the rest of Mingw 'off_t' should IMHO be guarded by _NO_OLDNAMES, regardless of the "poison".
Nope. _NO_OLDNAMES and __STRICT_ANSI__ serve two distinct purposes. Yes, _NO_OLDNAMES is a MinGW feature, but it is by no means synonymous with Microsoft's __ANSI__; the MinGW (GCC) equivalent for that would be __STRICT_ANSI__.
POSIX says off_t should be a standard type; MSDN says likewise. Thus, I can make it always visible as such. ANSI C99 makes no mention of off_t; therefore implicitly it should not be exposed, when __STRICT_ANSI__ is in effect. Unfortunately, because you poisoned the ticket with Microsoft source, I can't now apply the obvious correction, without fear of it being seen as plagiarism of the Microsoft code.
In any case, _NO_OLDNAMES is *definitely* *not* the correct guard here. _NO_OLDNAMES is explicitly to hide names which Microsoft did use at one time, (and which MinGW still supports), but they have now *replaced*, with underscore prefixed alternatives. `off_t' doesn't fall into this category; according to MSDN it is still defined as a *synonym* for `_off_t', not as having been *superseded* by it.
__STRICT_ANSI__ should not have any meaning to a file such as sys/types.h, since it is not mentioned in the ISO documentation, and hence is not covered by ISO C specification of standard names.
So, what's the conclusion ?
Remove _NO_OLDNAMES guard from off_t ?
Add ifdefs to ftruncate() declaration ?
I removed the _NO_OLDNAMES filter for off_t in sys/types.h.
Added notes to NEWS file.