tag:blogger.com,1999:blog-2349434231090974738.post1500652747903663654..comments2023-10-24T19:15:52.177+01:00Comments on Advanced C++ with Examples: 'auto' and 'register' variablesZahid Ghadialyhttp://www.blogger.com/profile/11618208626682295272noreply@blogger.comBlogger3125tag:blogger.com,1999:blog-2349434231090974738.post-3921739334555793922011-07-20T18:59:24.363+01:002011-07-20T18:59:24.363+01:00What the author might have missed here is that the...What the author might have missed here is that the compiler might have been forced to create an auto storage for the k variable, as an address for the variable was requested. A better test would be to disassemble to code:<br /><br />#include <br />int main(int argc, char **argv) {<br /> int i = 1;<br /> auto int j = 2;<br /> register int k = 3;<br /> register int l = 4;<br /> std::cout << i << " " << j << " " << k << " " << &l << std::endl;<br /> return 0;<br />}<br /><br />Snippet of assembly shows:<br />movl $1, -16(%rbp)<br />movl $2, -12(%rbp)<br />movl $3, %ebx<br />movl $4, -20(%rbp)<br /><br />At least my compiler is still respecting the register (though not recommending the coding style).Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-2349434231090974738.post-6488316477256206442011-05-29T20:28:03.754+01:002011-05-29T20:28:03.754+01:00I was searching on google and directed to this blo...I was searching on google and directed to this blog. I found it very informative. There are some very useful examples. Great work, Keep it up!java tutorialhttp://www.studiesinn.com/learn/Programming-Languages/Java-Language.htmlnoreply@blogger.comtag:blogger.com,1999:blog-2349434231090974738.post-11671074336864884092011-05-25T17:58:12.990+01:002011-05-25T17:58:12.990+01:00When programming at the firmware level, the keywor...When programming at the firmware level, the keyword "register" is used to indicate the existence of a memory location defined in the hardware as a having a special function. For example, the PC (program counter) is a "register". There may be a special purpose hardware "register" that may need writing to or reading from to get a task done. The keyword "register" along with the address of the memory location is needed in order to indicate to the compiler that it must access that particular memory location for these actions. So the interpretation of the keyword "register" depends on the compilers target system.Anonymousnoreply@blogger.com