Newsgroup: it.comp.lang.c
Titolo: aiuto con gli indicatori

 compiler, you don't know.
 From K&R2 (close, but not exactly, the C89 standard) A6.6:
   "Certain other conversions involving pointers and integers are
    permitted, but have implementation defined aspects.  They must
    be specified by an explicit type-conversion operator, or cast."
   "A pointer may be converted to an integral type large enough to
    hold it; the required size is implementation-dependent.  The
    mapping function is also implementation dependent."
   "An object of integral type may be explicitly converted to a
    pointer.  The mapping always carries a sufficiently wide integer
    converted from a pointer back to the same pointer, but is
    otherwise implementation-dependent."
Può qualcuno che conosca questo soggetto commentare il suddetto?
-- 
wade ward
"Nicht verzagen, Bruder Grinde fragen."

   
Può qualcuno che conosca questo soggetto commentare il suddetto?
A questo uno potrebbe chiedersi il perche' di tutte queste cose....
In realta' lo scambio interi/pointers ha solo alcune applicazioni 
abbastanza particolari e non dovrebbe essere abusato.
Quella che mi viene in mente e' la gestione di hardware, con mappe
di indirizzi espresse in valori interi che poi vengono assegnate 
a puntatori...
Ad ogni modo, queste operazioni sono molto legare al tipo di architettura
della CPU, alla dimensione dei tipi e quindi *poco* portabili, per cui.....
Brix

"brix" <brix99lu...@hotmail.invalid> wrote in message 
news:5MiRi.13601$ga5....@tornado.fastwebnet.it...

Thanks for your reply.  I couldn't save my life to speak Italian, unless the 
topic is wine or well-grown tomatoes.
Ora et labora.


 topic is wine or well-grown tomatoes.
Then, why did you post a message in an Italian newsgroup ???
Here the official language is Italian.
g.

"nano bagonghi" <nano.bag...@CUTgmail.com> wrote in message 
news:47177483$0$17952$4faf...@reader1.news.tin.it...

Ho inviato qui, perché la tribuna english-language per il linguaggio di 
programmazione di C è dominata dal uebertroll Keith Thompson e dai suoi 
flunkees. Ancora sto lavorando a tradurre la risposta.
salut,


Wade Ward ha scritto:

In such case, You have to specify that You do not spoke italian ;-)
BTW, general spoking about pointers and recasting...
in C You can assign a pointer to any other types, and vice-versa.
Of course not all the possible operations  may have a sense ................
1. defining a pointer and one integet type variable
     void* pippo;   /* This is a pointer*/
     long  pluto;   /* This is an 'integer' */
 You can assig the integer value to the pointer, but You have
 to recast it:
         pippo= (void*)pluto;
2. You can assign a pointer to the integer:
              pluto=(long)pippo;   /* fit a 32bit pointer into a 32bit 
ineger */
BUT you must be sure that the whole size of the pointer can fit into the 
integer:
for instance, on a 32bit CPU probably the pointer has a size of 32bit, 
so you
must choice an integer type big enougth to contains a 32bit value.....
    char data8;
    data8= (char)pippo;   /* Legal, but You have only the LSB part of 
pointer... */
    data8= pippo;   /* Implicit cast, Legal on some compiler, You may 
have a warning .... */
This is processor(and compile)-dependent: an int, for instance, on a 32bit
processor can be a 16bit size variable OR a 32bit size variable, so You 
should
better chose a long to hold a 32 bit type as a pointer...
sometimes some types are defined using 'typedef'  as int8_t, int16_t, 
int32_t etc............
to make  more portable the code...
Example:
typedef unsigned char uint8_t;    /* 8 bit  */
typedef short int16_t;                /* 16 bit (On CPU >=16bit, may be 
a 8bit on 8bit CPU) */
typedef  int  int16_t;                  /*  Ambiguous - 16 bit on 16bit 
CPU or 32bit CPU with some compiler controls */
typedef  int   int32_t;                 /* Ambiguous - not valid on 16 
bitCPU or 32bit CPU with some compiler controls */
typedef  long  int32_t;               /*  32bit  */
Trouble and confusion are bigger using compilers used for embedded 
development for little CPU....
The compiler has a file, limits.h, where You can find some usefull info.
Some notes: the pointer/integer conversions are *troubling* operations, 
that must
be done only for some very particular operations.
One of such operations involves hardware controls, where sometimes You 
have to program
addresses (pointers) in register locations, typically mapped as 
'integer' types.
In such special cases, may be usefull to take just a little part of the 
pointer, for intance
only the MSB byte of the pointer, and in such cases the flexibility of 
the C is very usefull.
Brix

 C is very useful.
brix: can you rewrite this last sentence in this paragraph?
Ringraziamenti per l'elaborazione. Il vostro inglese è molto buono. Have.got 
il mio compagno Michele che lavora al lato italiano di questo, così, il 
vostro sommario batterò il tempo fuori di quella traduzione. corteggii 
woo-hoo.
Notte di Beatiful qui nel Nuovo Messico.
Salut,



Sperando di esserte stato chiarificatore!
Ciao,
brix
"Il Tartaro m'avanza; e il prode ingegno
Han la tenaria Diva,
E l'atra notte, e la silente riva. "

>>>
tHE MOON WAS AT I^ AT 11.15 IN THE PM.
J_HAT IN 6 HANDS.
A DAY IS 24.
This number has unusual utility for algebraists.
-- 
wade ward

>>> ----------------
More tricky situations.  I don't understand the technical part of this 
paragraph.  Tja,
and ciao,
-- 
wade ward
