我用的是VC++6.0版的,这是我建立的源文件:
main.cpp
程序代码:# include "My_Assert.h"
int main()
{
ASSERT(1 == 0 , "Error") ;
return 0 ;
}这是assertion.h文件:
程序代码:#ifndef ASSERTION
#define ASSERTION
#ifdef __cplusplus
extern "C" {
#endif
void ASSERT(int exp , char *message);
#ifdef __cplusplus
}
#endif
#endif这是My_Assert.h文件:
程序代码:# include "assertion.h"
# include <stdio.h>
#ifdef __cplusplus
extern "C" {
#endif
void ASSERT(int exp , char *message)
{
if(!(exp))
printf("Assertion failed:\t%s\n%s:\t%d\t%s\n" ,#exp , message , __LINE__, __FILE__);
}
#ifdef __cplusplus
}
#endif老是在有下划线的地方指示有错误::\编程文件夹\char\my_assert.h(14) : error C2014: preprocessor command must start as first nonwhite space
e:\编程文件夹\char\my_assert.h(15) : error C2143: syntax error : missing ')' before '}'
e:\编程文件夹\char\my_assert.h(15) : error C2059: syntax error : ')'
这个是错误的报告!!!
不知道是为什么,很郁闷呀!!!
[ 本帖最后由 捕鱼者 于 2010-10-27 18:22 编辑 ]

