Deutsch   English   Français   Italiano  
<ucva4u$h0r$1@shakotay.alphanet.ch>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder8.news.weretis.net!news.imp.ch!news.alphanet.ch!alphanet.ch!.POSTED!not-for-mail
From: DrPi <314@drpi.fr>
Newsgroups: fr.comp.lang.ada
Subject: =?UTF-8?B?UmU6IFF1ZXN0aW9uIGRlIGfDqW7DqXJpY2l0w6k=?=
Date: Sat, 2 Sep 2023 14:34:35 +0200
Organization: Posted through news.alphanet.ch
Message-ID: <ucva4u$h0r$1@shakotay.alphanet.ch>
References: <uclnsh$fii$1@shakotay.alphanet.ch>
 <c3d74ebf-7153-4eb2-a22d-72b7c77ecf0bn@googlegroups.com>
 <uco7u8$156$1@shakotay.alphanet.ch>
 <26366041-5cd3-4ccf-b1ac-a937a1c53f3en@googlegroups.com>
 <ucql7j$vn3$1@shakotay.alphanet.ch>
 <a98095df-01d5-45ef-8bd3-ac2968e0a344n@googlegroups.com>
 <ucstqi$vg1$1@shakotay.alphanet.ch>
 <a36a4183-5817-4efa-86ee-09e4d883bb23n@googlegroups.com>
 <ucupkv$3ke$1@shakotay.alphanet.ch>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 2 Sep 2023 12:34:38 -0000 (UTC)
Injection-Info: shakotay.alphanet.ch; posting-account="dr.pi";
	logging-data="17435"; mail-complaints-to="usenet@alphanet.ch"; posting-host="bda8ab3c43e8ad8cb626bfebe8390999.nnrp.alphanet.ch"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha256:ldd160sdOKbcviQNh9/N4A/67g3tD1YD07u672eiyTc=
In-Reply-To: <ucupkv$3ke$1@shakotay.alphanet.ch>
Content-Language: fr
Bytes: 3141
Lines: 33

>> Une question à mon tour: pourquoi le choix 32, 64, 128 (puissances de 
>> deux) puis 255 (=2^8 - 1) et pourquoi +2 pour la longueur des trois 
>> premiers tableaux et +1 pour le dernier?
>>
> Je ne sais pas :p
> J'essaie de m'interfacer sur une DLL dont le fichier d'entête associé 
> définit les choses comme ça.
> 
> //  String types. These include room for the strings and a NULL char,
> //  or, on the Mac, a length byte followed by the string.
> //  TW_STR255 must hold less than 256 chars so length fits in first byte.
> #if defined(__APPLE__)--   cf: Mac version of TWAIN.h
>      typedef unsigned char TW_STR32[34],     FAR *pTW_STR32;
>      typedef unsigned char TW_STR64[66],     FAR *pTW_STR64;
>      typedef unsigned char TW_STR128[130],   FAR *pTW_STR128;
>      typedef unsigned char TW_STR255[256],   FAR *pTW_STR255;
> #else
>      typedef char          TW_STR32[34],     FAR *pTW_STR32;
>      typedef char          TW_STR64[66],     FAR *pTW_STR64;
>      typedef char          TW_STR128[130],   FAR *pTW_STR128;
>      typedef char          TW_STR255[256],   FAR *pTW_STR255;
> #endif
> 

Je pense que j'ai trouvé la réponse.
Les types TW_STRXXX sont utilisés dans des structures encapsulées dans 
une directive "#pragma pack (2)".
Donc TW_STR32 a 32 octets pour les caractères + 1 octet pour le zéro de 
fin de chaîne + 1 octet d'alignement.
Pareil pour les autres. Sauf TW_STR255 qui n'a pas besoin d'octet 
d'alignement.
En théorie, il n'y a pas besoin de cet octet d'alignement puisque la 
directive "pack" est là pour ça. Mais peut-être qu'en pratique, avec 
certains compilateurs, il faut l'ajouter.