난하려면 openssl 소스 코드, here에서 이상한 관용구를 발견하고 다음 반복 :이 C 관용구 (if (1))는 무엇입니까?
if ((in == NULL) && (passwds == NULL)) {
#ifndef OPENSSL_NO_UI
/* build a null-terminated list */
static char *passwds_static[2] = { NULL, NULL };
passwds = passwds_static;
if (in == NULL)
if (EVP_read_pw_string
(passwd_malloc, passwd_malloc_size, "Password: ",
!(passed_salt || in_noverify)) != 0)
goto end;
passwds[0] = passwd_malloc;
#else
BIO_printf(bio_err, "password required\n");
goto end;
#endif
}
내가 몇 가지 설명을 배제 :에
if ((in == NULL) && (passwds == NULL)) {
if (1) { (* <---- HERE *)
#ifndef OPENSSL_NO_UI
/* build a null-terminated list */
static char *passwds_static[2] = { NULL, NULL };
passwds = passwds_static;
if (in == NULL)
if (EVP_read_pw_string
(passwd_malloc, passwd_malloc_size, "Password: ",
!(passed_salt || in_noverify)) != 0)
goto end;
passwds[0] = passwd_malloc;
} else {
#endif
BIO_printf(bio_err, "password required\n");
goto end;
}
}
그것은 코드의이 작품은 동등 보인다
passwds_static
에 대한 블록 범위를 도입 할 수 있지만, 포함하는if
은 sim ilar 목적- 몇 가지 의미있는 변환을 통해 의미가 없지만 그 구조는 since the introduction of
OPENSSL_NO_UI
인 구조 일 수 있습니다.
여기에 뭔가가 빠졌습니까? 이 if (1)
의 장점은 무엇입니까? 다른 코드베이스에서 사용됩니까?
감사합니다.
기타 유사한 장소에서 찾고 후
그것의 유일한 목적은 어떤 이유에서 건 'else else'절을 피하는 것입니다. – StoryTeller
Dup of http://stackoverflow.com/questions/2266060/why-would-somebody-use-an- if-1-c-preprocessor-directive? – CristiFati
@CristiFati - 아니요. # if 1에 관한 것은 아닙니다. 왜냐하면 그 구조가 질문에 전혀 나타나지 않기 때문입니다. 그것은'if (1)'에 관한 것입니다. – StoryTeller