Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > C/C++: Системное программирование и WinAPI > UNREFERENCED_PARAMETER


Автор: Ap0k 7.1.2006, 17:12
Плиз, обясните что это за функция и для чего она предназначена.

Автор: Fixin 7.1.2006, 17:15
дословный перевод - "невызванные параметры". ты где это взял?

Автор: Ap0k 7.1.2006, 17:16
Это автоматически генерирует Visual Studio 2005 в WinMain функции.

Автор: Aleksandor 7.1.2006, 17:21
WINNT.H

//
// Macros used to eliminate compiler warning generated when formal
// parameters or local variables are not declared.
//
// Use DBG_UNREFERENCED_PARAMETER() when a parameter is not yet
// referenced but will be once the module is completely developed.
//
// Use DBG_UNREFERENCED_LOCAL_VARIABLE() when a local variable is not yet
// referenced but will be once the module is completely developed.
//
// Use UNREFERENCED_PARAMETER() if a parameter will never be referenced.
//
// DBG_UNREFERENCED_PARAMETER and DBG_UNREFERENCED_LOCAL_VARIABLE will
// eventually be made into a null macro to help determine whether there
// is unfinished work.
//
#if ! defined(lint)
#define UNREFERENCED_PARAMETER(P) (P)
#define DBG_UNREFERENCED_PARAMETER(P) (P)
#define DBG_UNREFERENCED_LOCAL_VARIABLE(V) (V)

#else // lint

// Note: lint -e530 says don't complain about uninitialized variables for
// this varible. Error 527 has to do with unreachable code.
// -restore restores checking to the -save state

#define UNREFERENCED_PARAMETER(P) \
/*lint -save -e527 -e530 */ \
{ \
(P) = (P); \
} \
/*lint -restore */
#define DBG_UNREFERENCED_PARAMETER(P) \
/*lint -save -e527 -e530 */ \
{ \
(P) = (P); \
} \
/*lint -restore */
#define DBG_UNREFERENCED_LOCAL_VARIABLE(V) \
/*lint -save -e527 -e530 */ \
{ \
(V) = (V); \
} \
/*lint -restore */

#endif // lint

Автор: Ap0k 7.1.2006, 17:24
Спасибо. Если я правильно понял, то с помощью этого макроса переменная переданная ему в качестве параметра помечается неиспользуемой?

Автор: Aleksandor 7.1.2006, 19:27
Я так думаю чтобы компилятор не выдавал предупреждений о том что переменная или параметр не используются.

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)