标题:自己写的函数怎么会出现预处理方面的错误呢?望高手解决!
取消只看楼主
捕鱼者
Rank: 2
等 级:禁止访问
帖 子:10
专家分:14
注 册:2010-10-21
结帖率:100%
已结贴  问题点数:20 回复次数:1 
自己写的函数怎么会出现预处理方面的错误呢?望高手解决!
这是我自己尝试写的函数,可是却不知道为什么老是报错:
贴出来:

为什么会出现的报错呢呀???希望高手帮忙解决一下呀!!!现非常感谢!
搜索更多相关主题的帖子: 函数 预处理 
2010-10-27 18:03
捕鱼者
Rank: 2
等 级:禁止访问
帖 子:10
专家分:14
注 册:2010-10-21
得分:0 
代码是:
我用的是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 编辑 ]
2010-10-27 18:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-324169-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.260643 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved