· Начало · Отвђтить · Статистика · Поиск · FAQ · Правила · Установки · Язык · Выход · WASM.RU · Noir.Ru ·

 WASM Phorum —› WASM.HEAP —› If the function succeeds, the return value is nonzero.

Посл.отвђт Сообщенiе


Дата: Авг 16, 2004 11:55:23

subj. Так почти всегда пишут в MSDN. Но вот, интересно так как MS с каждой виндой меняет ядро => есть вариант, что однажды вместо 1 в eax придет 2, или еще чё нибудь. У меня в некоторых софтах есть код:
.if eax==TRUE ;1
    ...Какие-либо действия
.endif

Естественно после прихода 2 вместо 1 получим неправильно работающий код :(
Конечно можно переделать:
.if eax!=FALSE ;1
    ...Какие-либо действия
.endif

Как же в таком случае буде правильнее ?


Дата: Авг 16, 2004 12:21:12

ChS
Нельзя предполагать, что TRUE - единица.
Я всегда сравниваю с нулем
or eax,eax   ; или test eax,eax
jz пришел_ноль
jnz пришел_не_ноль


Дата: Авг 16, 2004 12:52:21

Да, наверное идиотский вопрос. Я так понимаю всегда надо сравнивать с FALSE или 0.


Дата: Авг 16, 2004 13:03:03

A MS никогда и не позиционировала свои API как возвращающие TRUE в случае успеха, чаще это "nonzero" или "zero"(NULL) ;-)


Дата: Авг 16, 2004 13:11:53

Asterix
Ну, почему же, BOOL SetFileTime... возвращает TRUE или FALSE


Дата: Авг 16, 2004 14:35:01 · Поправил: Asterix

The SetFileTime function sets the date and time that a file was created,
last accessed, or last modified. 

BOOL SetFileTime(

    HANDLE hFile,	// identifies the file 
    CONST FILETIME *lpCreationTime,	// time the file was created 
    CONST FILETIME *lpLastAccessTime,	// time the file was last accessed 
    CONST FILETIME *lpLastWriteTime 	// time the file was last written 
   );	
 

Parameters

hFile

Identifies the file for which to set the dates and times. The file handle
must have been created with GENERIC_WRITE access to the file. 

lpCreationTime

Points to a FILETIME structure that contains the date and time the file
was created. This parameter can be NULL if the application does not need
to set this information. 

lpLastAccessTime

Points to a FILETIME structure that contains the date and time the file
was last accessed. The last access time includes the last time the file
was written to, read from, or (in the case of executable files) run.
This parameter can be NULL if the application does not need to set this
information. 

lpLastWriteTime

Points to a FILETIME structure that contains the date and time the file
was last written to. This parameter can be NULL if the application
does not want to set this information.  

 

Return Values

If the function succeeds, the return value is nonzero.

;-)


Дата: Авг 16, 2004 14:43:30

Читать я и сам умею :0) Как раз на этой функции и задумался.


Дата: Авг 16, 2004 15:03:35

вообще в сях понятия true/false нету. то что 0 считается false, _все_остальное_ - true. Так что они правильно пишут.


Дата: Авг 16, 2004 16:04:44

В правилах хорошего тона для С и иже подобных написано:
"во всех сравненияъ старайтесь использовать 0 (ноль)..."
с одной стороны это позволяет компиляторам меньше трудиться оптимизируя написанное вами %))),
ну...а с другой я вижу еще одну причину - maintainability


Powered by miniBB 1.6 © 2001-2002
Время загрузки страницы (сек.): 0.048