Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2006-11

size of "long" on different platforms

13 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Den Jean

Hi,

the c long int type is always mapped to longint in h2pas

but I guess this is not correct in linux (have no 64 bit to verify)

If I am correct:
linux64: c long int -> pascal int64
win64 : c long int -> pascal longint
What is the size of long on the Mac Os X platform ?

Is there a pascal integer type defined somewhere in rtl that allows me to map to this c-type sometimes
used in api's ?

Qt4 API sample
 bool myEventFilter(void *message, long *result);

my current definition

  PLong = ^Long;
{$ifdef CPU64 and not WIN64}
   Long = Int64;
{$else}
   Long = LongInt;
{$endif}

kind regards,

Den Jean

Jonas Maebe
to Den Jean
Den Jean wrote
Is there a pascal integer type defined somewhere in rtl that allows me to map to this c-type sometimes used in api's ?

There's a unit called ctypes in the rtl with all these types defined (prefixed by "c", i.e. cshort, cchar, clong, ...)

Jonas

Den Jean
to Jonas Maebe
Jonas Maebe wrote
There's a unit called ctypes in the rtl with all these types defined (prefixed by "c", i.e. cshort, cchar, clong, ...)

thx,

I do not see the win64 exception in the defines ??

regards,

Den Jean

Florian Klaempfl
to Den Jean
Show quoted text 9 lines
On Tuesday 14 November 2006 22:28, Jonas Maebe wrote: > There's a unit called ctypes in the rtl with all these types defined > (prefixed by "c", i.e. cshort, cchar, clong, ...) > thx, I do not see the win64 exception in the defines ??

Win64 has no such exceptions?

Daniël Mantione
to Пётр Косаревский: Why does rtl-documentation (http://community.freepascal.org:10000/docs-html/rtl/index.html…

Op Wed, 15 Nov 2006, schreef ???? ???????????:

Show quoted text 6 lines
> > On Tuesday 14 November 2006 22:28, Jonas Maebe wrote: > >> There's a unit called ctypes in the rtl with all these types defined > >> (prefixed by "c", i.e. cshort, cchar, clong, ...) Why does rtl-documentation (http://community.freepascal.org:10000/docs-html/rtl/index.html) lack its description? (it mentions 36 out of 48 base rtl units if I get it right)

We only have two hands and a limited number of
hours :) It hasn't been written yet.

Daniël

Michael Van Canneyt
to Пётр Косаревский: Why does rtl-documentation (http://community.freepascal.org:10000/docs-html/rtl/index.html…
???? ??????????? wrote 6 lines
> > On Tuesday 14 November 2006 22:28, Jonas Maebe wrote: > >> There's a unit called ctypes in the rtl with all these types defined > >> (prefixed by "c", i.e. cshort, cchar, clong, ...) Why does rtl-documentation (http://community.freepascal.org:10000/docs-html/rtl/index.html) lack its description? (it mentions 36 out of 48 base rtl units if I get it right)

Well, if I could clone myself about 5 times, and gave each of my clones a laptop, food and drink for 3 months, then I would probably be able to document the 12 other units.

Michael.

Пётр Косаревский
> Why does rtl-documentation (http://community.freepascal.org:10000/docs-html/rtl/index.html) lack its description? > (it mentions 36 out of 48 base rtl units if I get it right)

Some units are difficult do document and require some qualification.

In the case of ctypes, I ran "fpdoc.exe --output=1.1 --package=rtl --input=ctypes.pp" (of course, it generates isolated bunch of html files), added between <p> and </p> in 'index.html':

This unit defines types equivalent to common types in C programs. Most names are easy to understand: they are slightly abbreviated C names with "<tt>c</tt>" or "<tt>pc</tt>" (pointer type) prefix.</p> <p><tt><span class="code"><a href="../ctypes/cint.html">cuint</a></span></tt>, <tt><span class="code"><a href="../ctypes/cuint.html">cuint</a></span></tt> and <tt><span class="code"><a href="../ctypes/csint.html">csint</a></span></tt> types are 32-bit wide.</p> <p>Currently (11.2006) only 3 type-definitions depend on processor architecture: <tt><span class="code"><a href="../ctypes/clong.html">clong</a></span></tt>, <tt><span class="code"><a href="../ctypes/cslong.html">cslong</a></span></tt> and <tt><span class="code"><a href="../ctypes/culong.html">culong</a></span></tt> are either 32 or 64 bits.

And it looks acceptable (it required one glance over tiny "ctypes.pp").

The only other thing needed is providing c-names of the types in the types list ('index-3.html' file, I can write them and send the file if needed).

That's somewhat lame, but not so bad: by the way, "fpdoc" fails with unhandled exception if the file name is wrong. Is it error enough to be submitted?

Den Jean
to Florian Klaempfl: Win64 has no such exceptions?
Florian Klaempfl wrote
> I do not see the win64 exception in the defines ?? Win64 has no such exceptions?

because I was not sure, I was posting.

Is WIN64 not LLP64 ?

http://en.wikipedia.org/wiki/64-bit

...
Another alternative is the LLP64 model that maintains compatibility with 32 bit code, by leaving both int and long as 32-bit. "LL" refers to the "long long" type, which is at least 64 bits on all platforms, including 32 bit environments. Most 64 bit compilers today use the LP64 model (including Solaris, AIX, HP, Linux, MacOS native compilers), Microsoft however decided to use the LLP64 model.
Note that a programming model is a choice made on a per compiler basis, and several can coexist on the same OS. However typically the programming model chosen by the OS API as primary model dominates.
...

does this mean that the long in

 bool myEventFilter(void *message, long *result);

is 32 bit on win64 ???

regards,

Den Jean

Florian Klaempfl
to Den Jean
Show quoted text 6 lines
does this mean that the long in bool myEventFilter(void *message, long *result); is 32 bit on win64 ???

Yes, iirc ;)

Marco van de Voort
to Florian Klaempfl: Win64 has no such exceptions?
Show quoted text 12 lines
Den Jean schrieb: > On Tuesday 14 November 2006 22:28, Jonas Maebe wrote: > >> There's a unit called ctypes in the rtl with all these types defined >> (prefixed by "c", i.e. cshort, cchar, clong, ...) >> > > thx, > > I do not see the win64 exception in the defines ?? Win64 has no such exceptions?

long is 32-bit on win64 afaik (longlong is 64-bit), it is defined as 64-bit in ctypes.