#1250 unistd.h doesn't work with -D_NO_OLDNAMES


because ftruncate() is declared as

int ftruncate(int, off_t)

instead of

int ftruncate(int, _off_t)

(at the bottom of the unistd.h)


  • Alexey Pushkin

    Alexey Pushkin - 2009-02-05
    • priority: 5 --> 3
  • Keith Marshall

    Keith Marshall - 2009-02-10

    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.

  • Keith Marshall

    Keith Marshall - 2009-02-13

    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').

  • Keith Marshall

    Keith Marshall - 2009-02-13

    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.

  • Kai Tietz

    Kai Tietz - 2009-02-13

    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
    to warnings.
    Do you think this is ok?"

  • Alexey Pushkin

    Alexey Pushkin - 2009-02-14

    Guys, sorry for "polluting" this report :-)

  • Keith Marshall

    Keith Marshall - 2009-02-15

    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).

  • Alexey Pushkin

    Alexey Pushkin - 2009-02-15

    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".

  • Keith Marshall

    Keith Marshall - 2009-02-16

    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.

  • Danny Smith

    Danny Smith - 2009-02-17

    __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.

  • Alexey Pushkin

    Alexey Pushkin - 2009-02-20

    So, what's the conclusion ?

    Remove _NO_OLDNAMES guard from off_t ?

    Add ifdefs to ftruncate() declaration ?

  • Earnie Boyd

    Earnie Boyd - 2012-10-22
    • labels: 104601 --> WSL (Windows System Libraries)
    • milestone: --> Feature_in_WSL_4.0
    • assigned_to: nobody --> earnie
    • status: open --> open-fixed
  • Earnie Boyd

    Earnie Boyd - 2012-10-22

    I removed the _NO_OLDNAMES filter for off_t in sys/types.h.

  • Earnie Boyd

    Earnie Boyd - 2012-10-22
    • status: open-fixed --> closed-fixed
  • Earnie Boyd

    Earnie Boyd - 2013-01-18
    • category: --> Feature_in_WSL_4.0
    • milestone: Feature_in_WSL_4.0 --> WSL
  • Earnie Boyd

    Earnie Boyd - 2013-02-16
    • labels: WSL (Windows System Libraries) --> release notes
    • status: closed-fixed --> closed
    • type: --> Bug
    • resolution: --> fixed
    • patch_attached: --> False
  • Earnie Boyd

    Earnie Boyd - 2013-02-23
    • labels: release notes -->
  • Earnie Boyd

    Earnie Boyd - 2013-02-23

    Added notes to NEWS file.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks