请注意,你在K& R 2中找不到它的原因是那本书 涵盖C(几乎 - )89,而不是C99。 br /> Richard I see a lot of use in function declarations, such as size_t fread(void* restrict ptr, size_t size, size_t nobj, FILE*restrict fp); but what does the keyword ''restrict'' mean? there is no definition foundin K&R 2nd. 解决方案 restrict keyword C99 supports the restrict keyword, which allows for certainoptimizations involving pointers. For example: void copy(int *restrict d, const int *restrict s, int n){while (n-- > 0)*d++ = *s++;} C++ does not recognize this keyword. A simple work-around for code that is meant to be compiled aseither C or C++ is to use a macro for the restrict keyword: #ifdef __cplusplus#define restrict /* nothing */#endif (This feature is likely to be provided as an extension by manyC++ compilers. If it is, it is also likely to be allowed as areference modifier as well as a pointer modifier.) [C99: ?§6.2.5, 6.4.1, 6.7.3, 6.7.3.1, 7, A.1.2, J.2][C++98: ?§2.11] a?¢ from http://david.tribble.com/text/cdiffs.htm#C99-restrict --burton samogradkruhft .at. gmailkruhft.blogspot.comwww.myspace.com/kruhftmetashell.blogspot.com restrict keyword C99 supports the restrict keyword, which allows for certain optimizations involving pointers. For example: void copy(int *restrict d, const int *restrict s, int n) { while (n-- > 0) *d++ = *s++; } C++ does not recognize this keyword. A simple work-around for code that is meant to be compiled as either C or C++ is to use a macro for the restrict keyword: #ifdef __cplusplus #define restrict /* nothing */ #endif (This feature is likely to be provided as an extension by many C++ compilers. If it is, it is also likely to be allowed as a reference modifier as well as a pointer modifier.) [C99: §6.2.5, 6.4.1, 6.7.3, 6.7.3.1, 7, A.1.2, J.2] [C++98: §2.11] ? from http://david.tribble.com/text/cdiffs.htm#C99-restrict but what optimizations invoving pointers? restrict keyword C99 supports the restrict keyword, And note that the reason you won''t find it in K&R 2 is that that bookcovers C(almost-)89, not C99. Richard 这篇关于“限制”是什么意思?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!
10-10 09:58