문제

I have an average c++ background however i haven't developed anything with MFC, and i came across a Lib which i need to make portable and there are alot of calls for assert for example

void putValue(LPCTSTR lpszValue)
    {
        ASSERT(AfxIsValidString(lpszValue));
                .
                .
                .
        }

and in MSDN

The most typical use of the ASSERT macro is to identify program errors during development. The argument given to ASSERT should be chosen so that it holds true only if the program is operating as intended. The macro evaluates the ASSERT argument and, if the argument expression is false (0), alerts the user and halts program execution. No action is taken if the argument is true (nonzero).

if i were to port this to be compiled in GCC, is the right thing to do is putting the condition in an if statement and throw an exception id the condition was valid?

도움이 되었습니까?

해결책

I think you can simply:

#ifndef ASSERT
#include <cassert>
#define ASSERT assert
#endif
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top