LWN.net Logo

Quotes of the week

Quotes of the week

Posted Aug 23, 2012 14:56 UTC (Thu) by cate (subscriber, #1359)
In reply to: Quotes of the week by pr1268
Parent article: Quotes of the week

So let return to use again the register keyword?

I think inline is like register. Very useful if you know the target machine, but it is difficult to make a correct assessment if the same optimization should be applied to all architectures.


(Log in to post comments)

Quotes of the week

Posted Aug 23, 2012 16:48 UTC (Thu) by zlynx (subscriber, #2285) [Link]

The register keyword is quite handy for cases where you would like it to be in a register because the compiler will prevent the programmer from messing up the possibility.

For example:
register-test.c:7:2: error: address of register variable ā€˜i’ requested

GCC does not allow the programmer to get the address of a "register" variable.

So it is like "const." It keeps you from doing something dumb.

Quotes of the week

Posted Sep 3, 2012 8:37 UTC (Mon) by philomath (guest, #84172) [Link]

It's not GCC, it's the standard.

Quotes of the week

Posted Sep 3, 2012 16:47 UTC (Mon) by khim (subscriber, #9252) [Link]

Yup. And of course it does not work with C++ at all (that is: it's perfectly fine to take address of register variable in C++).

Quotes of the week

Posted Aug 23, 2012 19:13 UTC (Thu) by vonbrand (subscriber, #4458) [Link]

A long time ago, somebody told me there are three types of C compilers: Very smart ones, which disregard register because they do a better job at asigning values to registers than any static "this variable goes into a register" could possibly do; smart ones, which heed the register decoration when they can; and dumb ones which disregard register completely. GCC is one of the smarter ones around...

register

Posted Aug 25, 2012 0:00 UTC (Sat) by giraffedata (subscriber, #1954) [Link]

"disregard register because ..." sounds to me like it subsumes "disregard register completely." What is the difference between the very smart and dumb compilers?

register

Posted Aug 25, 2012 13:45 UTC (Sat) by mpr22 (subscriber, #60784) [Link]

The dumb one doesn't store variables in registers at all (other than transiently); everything is on the stack, because that's simpler to code the compilation behaviour for.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds