473,398 Members | 2,335 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,398 software developers and data experts.

Data type Qualifers

Hello everyone,

What are data type qualifers?

- Kuljit Singh Tomar
..

Mar 4 '06 #1
5 1807
"Kuljit" <ku**********@gmail.com> writes:
What are data type qualifers?


const, restrict, and volatile
--
"We put [the best] Assembler programmers in a little glass case in the hallway
near the Exit sign. The sign on the case says, `In case of optimization
problem, break glass.' Meanwhile, the problem solvers are busy doing their
work in languages most appropriate to the job at hand." --Richard Riehle
Mar 4 '06 #2

"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@benpfaff.org...
"Kuljit" <ku**********@gmail.com> writes:
What are data type qualifers?


const, restrict, and volatile


Type qualifiers modify the way the data is used or accessed. Many
non-standard "attributes" are implemented as type qualifiers: cdecl,
stdcall, __fastcall, __w64, __thread, noreturn, __malloc__, format,
__attribute, __attribute_used__, __declspec, etc.

Pre-ANSI versions of C usually #define const, restrict, or volatile to
nothing. If your C code doens't work properly without the type qualifiers,
you have a coding error. Using a type qualifier to _fix_ a problem should
be a 'red flag' that something is incorrect.
Rod Pemberton
Mar 5 '06 #3
"Rod Pemberton" <do*********@sorry.bitbucket.cmm> writes:
Type qualifiers modify the way the data is used or accessed. Many
non-standard "attributes" are implemented as type qualifiers: cdecl,
stdcall, __fastcall, __w64, __thread, noreturn, __malloc__, format,
__attribute, __attribute_used__, __declspec, etc.


In the implementations that I am familiar with, the __thread
extension is a storage class, not a type qualifier.
--
int main(void){char p[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv wxyz.\
\n",*q="kl BIcNBFr.NKEzjwCIxNJC";int i=sizeof p/2;char *strchr();int putchar(\
);while(*q){i+=strchr(p,*q++)-p;if(i>=(int)sizeof p)i-=sizeof p-1;putchar(p[i]\
);}return 0;}
Mar 5 '06 #4
"Rod Pemberton" <do*********@sorry.bitbucket.cmm> writes:
[...]
Pre-ANSI versions of C usually #define const, restrict, or volatile to
nothing.


No. Code intended to run on pre-ANSI C implementations may #define
them to nothing, but the implementations themselves wouldn't do so.

--
Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
Mar 5 '06 #5
Rod Pemberton wrote:
"Ben Pfaff" <bl*@cs.stanford.edu> wrote in message
news:87************@benpfaff.org...
"Kuljit" <ku**********@gmail.com> writes:

What are data type qualifers?


const, restrict, and volatile

Type qualifiers modify the way the data is used or accessed. Many
non-standard "attributes" are implemented as type qualifiers: cdecl,
stdcall, __fastcall, __w64, __thread, noreturn, __malloc__, format,
__attribute, __attribute_used__, __declspec, etc.

Pre-ANSI versions of C usually #define const, restrict, or volatile to
nothing. If your C code doens't work properly without the type qualifiers,
you have a coding error. Using a type qualifier to _fix_ a problem should
be a 'red flag' that something is incorrect.


I'd agree for `const' and `restrict', but not for
`volatile'.

int func(void) {
jmp_buf buff;
int value = 0;
while (setjmp(buff) == 0) {
otherfunc(value++);
}
return value;
}

This code has an error, and the fix is to add `volatile'
to the declaration of `value'.

--
Eric Sosman
es*****@acm-dot-org.invalid
Mar 5 '06 #6

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

Similar topics

4
by: Thomas Paul Diffenbach | last post by:
Can anyone point me to an open source library of /statically allocated/ data structures? I'm writing some code that would benefit from trees, preferably self balancing, but on an embedded system...
4
by: Dan | last post by:
I'm trying to creat a data structure, that can be either a integer, double, string, or linked list. So I created the following, but don't know if it is the data structure itself causing problems,...
18
by: Joel Hedlund | last post by:
Hi! The question of type checking/enforcing has bothered me for a while, and since this newsgroup has a wealth of competence subscribed to it, I figured this would be a great way of learning...
8
MMcCarthy
by: MMcCarthy | last post by:
Type MemSize RetVal of VarType() Declaration Char Conversion Boolean 2b vbBoolean(11) CBool() Byte 1b vbByte(17) ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.