Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Can volatile be added through declarations

Reply
Thread Tools

Can volatile be added through declarations

 
 
lovecreatesbea...@gmail.com
Guest
Posts: n/a
 
      12-11-2007
Can type qualifiers be added through declarations


For example, I have one variable defined in file scope without type
qualifier. In another file, say f1.c, this variable is declared with
two qualifiers added, and in the third file f2.c, declared with only
one qualifier added.

Will the variable act just as what they are declared in each file? Is
it a const and volatile variable in f1.c and only volatile in f2.c?



/* definition.c
************************************************** *************/
/*no qualifier added*/
int g_value = 0;


/* f1.c
************************************************** *********************/
int f1(void)
{
/*two qualifiers added: volatile, const*/
extern int volatile const g_value;

/*...*/
return 0;
}


/* f2.c
************************************************** *********************/
int f2(void)
{
/*one qualifiers added: volatile*/
extern int volatile g_value;

/*...*/
return 0;
}



Thank you for your time.
 
Reply With Quote
 
 
 
 
Eric Sosman
Guest
Posts: n/a
 
      12-11-2007
(E-Mail Removed) wrote:
> Can type qualifiers be added through declarations
>
>
> For example, I have one variable defined in file scope without type
> qualifier. In another file, say f1.c, this variable is declared with
> two qualifiers added, and in the third file f2.c, declared with only
> one qualifier added.
>
> Will the variable act just as what they are declared in each file? Is
> it a const and volatile variable in f1.c and only volatile in f2.c?


The behavior is undefined.

6.7.3p9: "For two qualified types to be compatible,
both shall have the identically qualified version
of a compatible type [...]"

6.2.7p2: "All declarations that refer to the same
object or function shall have compatible type;
otherwise, the behavior is undefined."

--
Eric Sosman
http://www.velocityreviews.com/forums/(E-Mail Removed)lid
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solution for posterity: GridView, Datakeys, and "Item has already been added. Key in dictionary: 'CategoryID' Key being added: 'CategoryID'" ASP .Net 2 11-02-2006 04:48 AM
Neither IE-Debugger or Mozilla/Venkman debugger can step through dynamically added code? Robert Oschler Javascript 1 09-05-2005 07:17 AM
Use of the Volatile keyword for a pointer to a volatile memory block ben C Programming 5 01-11-2005 05:38 PM
how come user control added to page doesn't get added to codebehind file? Bennett Haselton ASP .Net 1 11-08-2004 09:26 PM
Can volatile be trusted? Daniel Java 7 09-12-2003 10:19 AM



Advertisments