A pointer is a pointer. do a sizeof on char ptr, do a sizeof on int
ptr, you will see that both are same on a system, which is equal to
the sizeof system - word. also a hex literal like 0x123 is inherently
a unsigned int literal.

unsigned char* ptr just states the behavior when its dereferenced.



On Wed, Jun 10, 2009 at 2:14 PM, Sharma, Hans Raj
(London)<[email protected]> wrote:
>
>
> Thanks James.
>
> That clears my concept. Just one doubt, are you talking about CPU
> registers below? Can we get address of them? How?
>
> Regards,
>
> Hans Raj
>
> From: [email protected] [mailto:[email protected]] On Behalf
> Of John Matthews
> Sent: Wednesday, June 10, 2009 1:27 PM
> To: [email protected]
> Subject: [c-prog] Re: Volatile variable in C
>
> --- In [email protected] <mailto:c-prog%40yahoogroups.com> ,
>
> "Sharma, Hans Raj \(London\)" <hansraj_sha...@...> wrote:
>>
>> Can someone please help me understand how can I write a program which,
>> using volatile variable, access some memory mapped devices?
>
> If you have an 8 bit register at address 0x1234 containing an unsigned 8
> bit value, then you might do something like:
>
> volatile unsigned char *const reg = 0x1234;
>
> printf("reg = %u\n", *reg);
>
> It might work without the volatile, but the volatile tells the compiler
> that the contents of the register might change outside of the thread's
> control eg. because another thread is modifying it. Thus it shouldn't do
> any optimizations which assume its value is constant between accesses.
>
> ----------------------------------------------------------
> This message w/attachments (message) may be privileged, confidential or
> proprietary, and if you are not an intended recipient, please notify the
> sender, do not use or share it and delete it. Unless specifically indicated,
> this message is not an offer to sell or a solicitation of any investment
> products or other financial product or service, an official confirmation of
> any transaction, or an official statement of Merrill Lynch. Subject to
> applicable law, Merrill Lynch may monitor, review and retain
> e-communications (EC) traveling through its networks/systems. The laws of
> the country of each sender/recipient may impact the handling of EC, and EC
> may be archived, supervised and produced in countries other than the country
> in which you are located. This message cannot be guaranteed to be secure or
> error-free. References to "Merrill Lynch" are references to any company in
> the Merrill Lynch & Co., Inc. group of companies, which are wholly-owned by
> Bank of America Corporation. Securities and Insurance Products: * Are Not
> FDIC Insured * Are Not Bank Guaranteed * May Lose Value * Are Not a Bank
> Deposit * Are Not a Condition to Any Banking Service or Activity * Are Not
> Insured by Any Federal Government Agency. Attachments that are part of this
> E-communication may have additional important disclosures and disclaimers,
> which you should read. This message is subject to terms available at the
> following link: http://www.ml.com/e-communications_terms/. By messaging with
> Merrill Lynch you consent to the foregoing.
> ----------------------------------------------------------
>
>
> [Non-text portions of this message have been removed]
>
> 

Reply via email to