473,394 Members | 1,811 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Can volatile be added through declarations

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.
Dec 11 '07 #1
1 1194
lovecreatesbea...@gmail.com 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
es*****@ieee-dot-org.invalid
Dec 11 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Anh-Tu Vo | last post by:
Hi all, I have a weird problem on a variable assignment. It seems that the variable is only updated with the value at the second time the function is called. My program looks like this: ...
8
by: David Rasmussen | last post by:
What is the difference in meaning and in consequences between struct S { volatile A* a; }; and struct S
3
by: Christopher M. Lusardi | last post by:
Hello, Can you tell me is it my imagination, or should I not stick a "volatile" definition into a dot h file? My problem is if I put my declaration in main.c before main () my code works....
5
by: ben | last post by:
Hello All, I am trying to make sense of a bit of syntax, is there a guru out there that can clear this up for me. I have a buffer declared as static volatile u8 buffer; and I have a...
14
by: Ian Pilcher | last post by:
It's pretty common to see declarations such as: static volatile sig_atomic_t caught_signal = 0; C99 defines sig_atomic_t as a "... (possibly volatile-qualified) integer type of an object that...
13
by: yaron | last post by:
Hi all, let be focus on sigle processor machine 32 bits. 1. with multi-threaded on single processor machine 32bit do i have to sync access to atomic get/set properties of type less then 32 bits...
6
by: venky | last post by:
Hi all, I'm new to group n c. i want to know in detail about volatile qualifier and pointer to functions with examples. thank you
94
by: Samuel R. Neff | last post by:
When is it appropriate to use "volatile" keyword? The docs simply state: " The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock...
3
by: C++Liliput | last post by:
It seems that the keyword "volatile" is used to make sure that threads reading (or writing to) the same data should see a consistent picture of the variable i.e. updates made to the common data...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.