Jump to page: 1 2
Thread overview
[Issue 2364] New: ftell return type is long in C, that is 64-bit on x86-64
Sep 17, 2008
d-bugmail
Sep 18, 2008
downs
Sep 18, 2008
Sean Kelly
Sep 18, 2008
Denis Koroskin
Oct 09, 2008
d-bugmail
Oct 09, 2008
d-bugmail
Oct 10, 2008
d-bugmail
Oct 10, 2008
d-bugmail
Oct 19, 2009
Sobirari Muhomori
Oct 19, 2009
Brad Roberts
September 17, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2364

           Summary: ftell return type is long in C, that is 64-bit on x86-64
           Product: D
           Version: 2.019
          Platform: PC
               URL: http://digitalmars.com/d/2.0/phobos/std_c_stdio.html#fte
                    ll
        OS/Version: Windows
            Status: NEW
          Severity: trivial
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: terranium@yandex.ru


But in D it's declared as int ftell(FILE *);


-- 

September 18, 2008
d-bugmail@puremagic.com wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=2364
> 
>            Summary: ftell return type is long in C, that is 64-bit on x86-64
>            Product: D
>            Version: 2.019
>           Platform: PC
>                URL: http://digitalmars.com/d/2.0/phobos/std_c_stdio.html#fte
>                     ll
>         OS/Version: Windows
>             Status: NEW
>           Severity: trivial
>           Priority: P2
>          Component: Phobos
>         AssignedTo: bugzilla@digitalmars.com
>         ReportedBy: terranium@yandex.ru
> 
> 
> But in D it's declared as int ftell(FILE *);
> 
> 

So .. ptrdiff_t?
September 18, 2008
downs wrote:
> d-bugmail@puremagic.com wrote:
>> http://d.puremagic.com/issues/show_bug.cgi?id=2364
>>
>>            Summary: ftell return type is long in C, that is 64-bit on x86-64
>>            Product: D
>>            Version: 2.019
>>           Platform: PC
>>                URL: http://digitalmars.com/d/2.0/phobos/std_c_stdio.html#fte
>>                     ll
>>         OS/Version: Windows
>>             Status: NEW
>>           Severity: trivial
>>           Priority: P2
>>          Component: Phobos
>>         AssignedTo: bugzilla@digitalmars.com
>>         ReportedBy: terranium@yandex.ru
>>
>>
>> But in D it's declared as int ftell(FILE *);
>>
>>
> 
> So .. ptrdiff_t?

Nope, C long.  So 32 bits on Win32, Win64, and 32-bit *nix, but 64 bits on 64-bit *nix.
September 18, 2008
On Thu, 18 Sep 2008 08:52:13 +0400, Sean Kelly <sean@invisibleduck.org> wrote:

> downs wrote:
>> d-bugmail@puremagic.com wrote:
>>> http://d.puremagic.com/issues/show_bug.cgi?id=2364
>>>
>>>            Summary: ftell return type is long in C, that is 64-bit on x86-64
>>>            Product: D
>>>            Version: 2.019
>>>           Platform: PC
>>>                URL: http://digitalmars.com/d/2.0/phobos/std_c_stdio.html#fte
>>>                     ll
>>>         OS/Version: Windows
>>>             Status: NEW
>>>           Severity: trivial
>>>           Priority: P2
>>>          Component: Phobos
>>>         AssignedTo: bugzilla@digitalmars.com
>>>         ReportedBy: terranium@yandex.ru
>>>
>>>
>>> But in D it's declared as int ftell(FILE *);
>>>
>>>
>>  So .. ptrdiff_t?
>
> Nope, C long.  So 32 bits on Win32, Win64, and 32-bit *nix, but 64 bits on 64-bit *nix.

Isn't it compiler specific? I.e. DMD declares C long as D int no matter what.
But I agree that it should return long (on 32-bit OS, too).
September 18, 2008
"Denis Koroskin" wrote
> On Thu, 18 Sep 2008 08:52:13 +0400, Sean Kelly <sean@invisibleduck.org> wrote:
>
>> downs wrote:
>>> d-bugmail@puremagic.com wrote:
>>>> http://d.puremagic.com/issues/show_bug.cgi?id=2364
>>>>
>>>>            Summary: ftell return type is long in C, that is 64-bit on
>>>> x86-64
>>>>            Product: D
>>>>            Version: 2.019
>>>>           Platform: PC
>>>>                URL:
>>>> http://digitalmars.com/d/2.0/phobos/std_c_stdio.html#fte
>>>>                     ll
>>>>         OS/Version: Windows
>>>>             Status: NEW
>>>>           Severity: trivial
>>>>           Priority: P2
>>>>          Component: Phobos
>>>>         AssignedTo: bugzilla@digitalmars.com
>>>>         ReportedBy: terranium@yandex.ru
>>>>
>>>>
>>>> But in D it's declared as int ftell(FILE *);
>>>>
>>>>
>>>  So .. ptrdiff_t?
>>
>> Nope, C long.  So 32 bits on Win32, Win64, and 32-bit *nix, but 64 bits on 64-bit *nix.
>
> Isn't it compiler specific? I.e. DMD declares C long as D int no matter
> what.
> But I agree that it should return long (on 32-bit OS, too).

Better answer: don't use ftell :)

But in case you have to, it seems that a version'd c_long is in order.

-Steve


October 09, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2364





------- Comment #1 from terranium@yandex.ru  2008-10-09 07:43 -------
> > So .. ptrdiff_t?
> 
> Nope, C long.  So 32 bits on Win32, Win64, and 32-bit *nix, but 64 bits on 64-bit *nix.

All c types are compiler-specific, but in fact long is 64 bit on x86-64 architecture (os-independent).


-- 

October 09, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2364





------- Comment #2 from matti.niemenmaa+dbugzilla@iki.fi  2008-10-09 12:17 -------
Nope, see for instance http://en.wikipedia.org/wiki/64-bit#64-bit_data_models or try MSVC yourself: sizeof(long) == 4.


-- 

October 10, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2364





------- Comment #3 from terranium@yandex.ru  2008-10-10 02:26 -------
... indeed. For some reason I thought different. Was it always like this?


-- 

October 10, 2008
http://d.puremagic.com/issues/show_bug.cgi?id=2364





------- Comment #4 from matti.niemenmaa+dbugzilla@iki.fi  2008-10-10 04:03 -------
Yes, I think it's always been like that.


-- 

October 19, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=2364


Sobirari Muhomori <dfj1esp02@sneakemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |INVALID


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
« First   ‹ Prev
1 2