Форум вопросов и ответов

Форум вопросов и ответов (https://www.otvetnemail.ru/)
-   Продолжение старого архива (https://www.otvetnemail.ru/prodolzhenie-starogo-arhiva-804/)
-   -   Каково отличие gcc __attribute__ ((pure)) от ключевого слова const (https://www.otvetnemail.ru/prodolzhenie-starogo-arhiva-804/kakovo-otlichie-gcc-__attribute__-pure-ot-klyuchevogo-slova-const-356904/)

Guest 30.09.2011 18:20

Каково отличие gcc __attribute__ ((pure)) от ключевого слова const
 
Официальное описание __attribute__ ((pure))ЦитироватьMany functions have no effects except the return value and their return value depends only on the parameters and/or global variables. Such a function can be subject to common subexpression elimination and loop optimization just as an arithmetic operator would be. These functions should be declared with the attribute pure. For example, int square (int) __attribute__ ((pure)); says that the hypothetical function square is safe to call fewer times than the program says.Some of common examples of pure functions are strlen or memcmp. Interesting non-pure functions are functions with infinite loops or those depending on volatile memory or other system resource, that may change between two consecutive calls (such as feof in a multithreading environment). Какая разница между функцией с атрибутом "pure" и const функцией?


Часовой пояс GMT, время: 03:48.


© www.otvetnemail.ru - Форум вопросов и ответов.