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

Re: Low-level vs. High-level programming



pausch@saaf.se (Paul Schlyter) wrote in
news:bd9004$22or$1@merope.saaf.se: 

> In article <bd6g35$tte$1@barad-dur.nas.com>,
> White Flame \(aka David Holz\) <whiteflame52@y.a.h.o.o.com> wrote:
>  
>> "Paul Schlyter" <pausch@saaf.se> wrote in message
>> news:bd696r$15en$1@merope.saaf.se...
>>>     unsigned int memory_address =
>>>     <address_of_memory_mapped_HW-device>; 
>> 
>> That's fairly ugly, and isn't guaranteed to work, since there's no
>> requirements that ints be as wide as pointers.
>  
> In such a situation, use a long int instead.....
>  
>> If memory_address were a void*, it would be quite kosher.
>  
> Wouldn't help much, since the value of the address would still have
> to be specified as a constant, and there are no (void *) constants in
> C. 
>  


void* is a pointer and in C++, one may opt to use const void* instead of
void*. So I would think you are correct in this assumption. const is
used to declare something as a constant. I am not sure that you can
const a void pointer in C but in C++, you can. 

White Flame, I hope you are not mixing in C++ with C. From what I
remember in C++ it is usually recommended that const void * be used
rather than void * as the type of pointer that will address a constant
value. I am sure that you know this. 

Whatever the subject is about, I am sure void * would be fine to use
unless constant values are to be addressed. I think that if you are
going to take a modern approach on this that we use const void * as
implied with C++ which is C extended with object-orientation. C++ is a
superset built on C. But additional stuff with C++ will not work with C.
Though it may be accurate to say that there are some C programs that may
not work with C++. 

Just noting my background in this.  I may not be following this clearly
due to lack of attention on this particular subject being discussed.