[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?
From: |
Benjamin Kowarsch |
Subject: |
Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2? |
Date: |
Fri, 14 Jul 2017 01:50:16 +0900 |
> On Jul 14, 2017, at 01:29, john o goyo <address@hidden> wrote:
>
>> Ncurses doesn't use size_t at all.
> You are quite correct. Apologies, I was pressed for time when I answered and
> misled you.
not a problem ;-)
>> size_t is a type that is defined as an alias of an unsigned integer type
>> large enough to express the largest possible index of a file. It is target
>> dependent. Thus if you have a platform with 64-bit file system support, then
>> size_t would need to be a 64-bit unsigned integer in order to express the
>> size of files of all possible sizes.
> The document gm2.info defines size_t as CARDINAL, at least in dealing with
> PTH.
That sounds a little suspicious.
Does GM2 guarantee that CARDINAL will *always* be the same size as size_t would
be when running gcc against the same target architecture? I am not sure it
does. If it doesn't, then it would be incorrect.
Say we build a 64-bit target and size_t is 64-bit. Would CARDINAL be 64-bit
then?
>
>> When defining a foreign definition module for a C API that uses size_t, like
>> stdio does, one needs to know what the current target's size of size_t is in
>> order to define an unsigned type in Modula-2 that matches the exact size of
>> size_t in C for that particular target.
> Indeed, POSIX recommends calling confstr(). As a datum point, the
> sys/types.h on Solaris checks against numerous constants (and even the C++
> version).
Trouble is that I cannot possibly call confstr() from within a definition
module in Modula-2.
GM2 will have to do the work. It needs to either provide a SIZET type in module
SYSTEM that always matches size_t for the current target, or it needs to
provide conditional compilation (don't know if it does) and a constant that
tells us what the target architecture is and then we can do some research or
find out by experiment what size_t would be for that target and define our own
SizeT type accordingly. Of course, considering the sheer number of different
targets that GCC supports, the safest way would be for the compiler to provide
a SIZET type in module SYSTEM.
But I guess, only Gaius can answer these questions.
regards
benjamin
- [Gm2] Interfacing to C -- How do we map size_t to Modula-2?, Benjamin Kowarsch, 2017/07/13
- Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?, john o goyo, 2017/07/13
- Message not available
- Message not available
- Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?,
Benjamin Kowarsch <=
- Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?, Benjamin Kowarsch, 2017/07/13
- Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?, Gaius Mulley, 2017/07/16
- Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?, Gaius Mulley, 2017/07/21
- Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?, Benjamin Kowarsch, 2017/07/24
- Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?, Gaius Mulley, 2017/07/26