首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

这个宏定义有错吗?该怎么处理

2012-03-26 
这个宏定义有错吗?#defineWRITE_COL5\do.BeginWrite()\do.RsCreate(5)\intcount0\while(ds eta1 e

这个宏定义有错吗?
#define   WRITE_COL5     \
do.BeginWrite();\
do.RsCreate(5);\
int   count   =   0;\
while   (ds   > >   eta1   > >   eta2   > >   eta3   > >   eta4   > >   eta5)\
{   \
count++;   \
do.RsAddRow();   \
do.RsSetCol(1,eta1);   \
do.RsSetCol(2,eta2);   \
do.RsSetCol(3,eta3);   \
do.RsSetCol(4,eta4);   \
do.RsSetCol(5,eta5);   \
do.RsSaveRow();   \
}\      
if   (count   ==   0)   \
{   \
string   message   =   "没有*** ";   \
throw   DTID(message);   \
}  

我在UNIX下编译竟然会报
Error   19:   "***.cpp ",   line   35   #   Unexpected   'if '.
                        if   (count   ==   0)   \
                        ^^
Error   24:   "***.cpp ",   line   35   #   '( '   expected   instead   of   '== '.
                        if   (count   ==   0)   \
                                            ^^
Error   20:   "***.cpp ",   line   36   #   ') '   expected   before   '{ '.
                        {   \
                        ^
Error   373:   "***.cpp ",   line   35   #   Old-style   function   definition   parameter   must   be   a   simple   identifier.
                        if   (count   ==   0)   \
                                                  ^
Error   43:   "***.cpp ",   line   35   #   C++   does   not   allow   Old-style   (non-prototype)   function   definitions.
                        if   (count   ==   0)   \
                              ^^^^^^^^^^^^^^
Warning   (anachronism)   600:   "***.cpp ",   line   35   #   Type   specifier   is   omitted;   "int "   is   no   longer   assumed.
                        if   (count   ==   0)   \
                                ^^^^^
Warning   361:   "***.cpp ",   line   35   #   Value-returning   function   might   end   without   executing   a   return   statement.
                        if   (count   ==   0)   \


                                ^^^^^
Error   1044:   "***.cpp ",   line   1114   #   Character   '\ '   (value   92)   was   unexpected.   Check   if   there   are   any   characters   or
        white-space   between   '\ '   and   newline.
                        WRITE_COL5
                        ^^^^^^^^^^^^^^^^^
***   Error   exit   code   2

Stop.
***   Error   exit   code   1


我感觉这样定义宏应该是对的,   想来想去都不知道错在哪???

[解决办法]
宏就是个字符串替换,没什么对错之分。
关键还要看用的地方。
[解决办法]
你是不是每个 "\ "后面没有空格??
如果“\”后面还有空格或者其他什么字符,好象就不会进行替换了。
[解决办法]
你的那个\后面有空格

热点排行