By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,710 Members | 1,626 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,710 IT Pros & Developers. It's quick & easy.

Data type Qualifers

P: n/a
Hello everyone,

What are data type qualifers?

- Kuljit Singh Tomar
..

Mar 4 '06 #1
Share this Question
Share on Google+
5 Replies


P: n/a
"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

P: n/a

"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

P: n/a
"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

P: n/a
"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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.