groff
[Top][All Lists]
Advanced

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

Re: [Groff] Using C with glib instead of C++ for groff


From: Doug Royer
Subject: Re: [Groff] Using C with glib instead of C++ for groff
Date: Fri, 29 Nov 2002 11:48:53 -0700
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0


This is incorrect.  ANSI C does not mandate `int' has 16 bits.


In my version of the ANSI C book of Kernighan/Ritchie, chapter B.11
on <limits.h> says

INT_MAX     +32767
INT_MIN     -32767
UINT_MAX     65535

This makes int and uint 16 bits types in ANSI C.

POSIX (&ANSI) system and C standards have a matrix
that describes the size.

It's not that simple.

           |         System Model
Data Type  |LP32 ILP32  ILP64  LLP64 LP64 |
-----------+----+-----+-------+-----+-----+
char       | 8  | 8   |  8    |  8  |  8  |
-----------+----+-----+-------+-----+-----+
short      | 16 | 16  | 16    |  16 |  16 |
-----------+----+-----+-------+-----+-----+
int32      |    |     | 32    |     |     |
-----------+----+-----+-------+-----+-----+
int        | 16 | 32  | 64    |  32 |  32 |
-----------+----+-----+-------+-----+-----+
long       | 32 | 32  | 64    |  32 |  64 |
-----------+----+-----+-------+-----+-----+
long long  |    |     |       |  64 |     |
  (int64)  |    |     |       |     |     |
-----------+----+-----+-------+-----+-----+
pointer    | 32 | 32  | 64    |  64 |  64 |
-----------+----+-----+-------+-----+-----+

And the [u]int{16,32,64}_t are obvious size.

And the [u]intptr_t == [un]signed int large enought to hold any pointer.

And readup on the POSIX sysconf() for c89 values:

  sysconf() value  |  int  | long  | pointer  | off_t
-------------------+-------+-------+----------+------+
_XBS5_ILP32_OFF32  |   32  |   32  |      32  |  32  |
-------------------+-------+-------+----------+------+
_XSB5_ILP32_OFFBIG |   32  |   32  |      32  | >=64 |
-------------------+-------+-------+----------+------+
_XBS5_LP64_OFF64   |   32  |   64  |      64  |   64 |
-------------------+-------+-------+----------+------+
_XSB5_LPBIG_OFFBIG | >=32  | >=64  |    >=64  | >=64 |
-------------------+-------+-------+----------+------+

In addition there are standard corrosponding C, LD, and LIB flags
that are defined to use/select/detect the standard sizes.
This works for CONFORMING C compilers and systems.

On Unix'OS there is often a nice explanation in <unistd.h>


--

 Doug Royer                     |   http://INET-Consulting.com
 -------------------------------|-----------------------------
 address@hidden                 | Office: (208)612-INET
 http://Royer.com/People/Doug   |    Fax: (866)594-8574
                                |   Cell: (208)520-4044

                We Do Standards - You Need Standards

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


reply via email to

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