gm2
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gm2] Fwd: Re: Interfacing to C -- How do we map size_t to Modula-2?


From: john o goyo
Subject: [Gm2] Fwd: Re: Interfacing to C -- How do we map size_t to Modula-2?
Date: Thu, 13 Jul 2017 12:30:58 -0400
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.5; en-GB; rv:1.9.2.23) Gecko/20110920 Thunderbird/3.1.15

Sending to gm2 list.

-------- Original Message --------
Subject:        Re: [Gm2] Interfacing to C -- How do we map size_t to Modula-2?
Date:   Thu, 13 Jul 2017 12:29:50 -0400
From:   john o goyo <address@hidden>
Reply-To:       address@hidden
To:     Benjamin Kowarsch <address@hidden>


On 13/07/2017 10:38, Benjamin Kowarsch wrote:
 On Jul 13, 2017, at 22:57, john o goyo<address@hidden>   wrote:

 I am writing a foreign definition module to interface to C.

 How do I map size_t to Modula-2?

 I would suggest looking at the interface to ncurses in the example directory.
 Thanks but I'm afraid, that doesn't tell me anything about how to map size_t.

 Ncurses doesn't use size_t at all.
You are quite correct. Apologies, I was pressed for time when I answered
and misled you.
 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.

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

 Gaius, can you shed some light on this please?

 thanks a lot in advance
 benjamin

Sincerely,
john





reply via email to

[Prev in Thread] Current Thread [Next in Thread]