Solved

Question with regard to Volatile type specifier!

Posted on 2004-04-18
8
202 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand opening and reading files in the C programming language.

825 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