4 ms·
Languages and compilers actually do have constructs for programmers to make things easier for the compiler. "inline" and "register" are two very known examples
by dkopi 11y ago
Languages and compilers actually do have constructs for programmers to make things easier for the compiler.
"inline" and "register" are two very known examples.
Other examples are function attributes in gcc:
https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
- nkurz 11y agoI presume you're aware that you've chosen two controversial examples? "register" has been formally deprecated in C++, and has been ignored by (almost?) all C compilers for decades: http://stackoverflow.com/questions/20618008/replacement-for-deprecated-register-keyword-c-11 http://stackoverflow.com/questions/20618008/replacement-for-... And most current wisdom is that "inline" no longer serves as a useful performance suggestion to the compiler, but instead should only be used as a linkage directive to allow multiple declarations of the same function: http://stackoverflow.com/questions/29796264/is-there-still-a-use-for-inline http://stackoverflow.com/questions/29796264/is-there-still-a...
- dkopi 11y agoGreat points. As compilers evolve, optimizers are even more knowledgeable of what should be put in a register or inline that the programmer. But those are still 2 well known features that were added intentionally to help improve performance.
- 0x07c0 11y agorestrict is probably a better example! https://en.wikipedia.org/wiki/Restrict https://en.wikipedia.org/wiki/Restrict
- dkopi 11y agogreat example