Solved

Question with regard to Volatile type specifier!

Posted on 2004-04-18
8
199 Views
Last Modified: 2010-04-15
Hi experts,

I'm just wondering what a volatile type specifier really does?  Is it essential in programming synchronization problem?

thanks

r6
0
Comment
Question by:R6
8 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 34 total points
ID: 10857096
check this link
http:Q_20684549.html
0
 
LVL 9

Assisted Solution

by:ankuratvb
ankuratvb earned 33 total points
ID: 10857409
0
 

Author Comment

by:R6
ID: 10861183
hi sunnycoder & ankuratvb,

thanks for helping me out!

heres my actual problem:

volatile struct can *theCan;
....
....


void *aFunc() {
  return theCan;
}

and the compiler signals a warning that says "warning: return discards qualifiers from pointer target type"

what does that really mean?

thank u!

r6



0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Assisted Solution

by:brad_1
brad_1 earned 33 total points
ID: 10864680
You declared the return type as a "void *"  and returned a "struct can *". The mismatch between these causes the compiler to issue a warning. Either change the return type to "struct can *", or cast the returned pointer to "void *".
e.g. return (void *) theCan;

I don't know if the volatile keyword is relevant to the return type.

Brad
0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10867321
Does the warning disappear if you remove the volatile from thecan's declaration.?

I cant test it myself coz on my compiler,i dont even get a warning.

BTW,what compiler are u using?

0
 
LVL 9

Expert Comment

by:ankuratvb
ID: 10867338
It shouldnt be because of the void * return type and you returning a struct can *
coz void pointers can be assigned to any kind of pointer without requiring an explicit cast and without loss of information.

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use structures in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now