C 为什么此多行宏不';不行?
看起来好像连包都没包好。但我觉得很好 也许它不喜欢新台词?在没有他们的情况下尝试过 也许它一定是大写的?我真的不知道 也许它不喜欢///评论C 为什么此多行宏不';不行?,c,macros,C,Macros,看起来好像连包都没包好。但我觉得很好 也许它不喜欢新台词?在没有他们的情况下尝试过 也许它一定是大写的?我真的不知道 也许它不喜欢///评论 #define fill(where_l, where_r, where_t, where_b, what_l, what_r, what_t, what_b) \ \ ////lt
#define fill(where_l, where_r, where_t, where_b, what_l, what_r, what_t, what_b) \
\
////lt \
*p++ = where_l; \
*p++ = where_t; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_l; \
*p++ = what_t; \
\
////rt \
*p++ = where_r; \
*p++ = where_t; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_r; \
*p++ = what_t; \
\
////lb \
*p++ = where_l; \
*p++ = where_b; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_l; \
*p++ = what_b; \
\
////rb \
*p++ = where_r; \
*p++ = where_b; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_r; \
*p++ = what_b; \
错误:
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(570) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(570) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(570) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(571) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(571) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(571) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(572) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(572) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(572) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(573) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(573) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(573) : error C2086: 'int *p' : redefinition
已完全删除评论,现在错误为:
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(569) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(570) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(570) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(570) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(571) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(571) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(571) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(572) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(572) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(572) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(574) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(574) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(574) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(575) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(575) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(575) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(576) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(576) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(576) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(577) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(577) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(577) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(578) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(578) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(578) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(579) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(579) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(579) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(581) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(581) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(581) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(582) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(582) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(582) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(583) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(583) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(583) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(584) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(584) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(584) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(585) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(585) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(585) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(586) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(586) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(586) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(588) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(588) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(588) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(589) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(589) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(589) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(590) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(590) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(590) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(591) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(591) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(591) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(592) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(592) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(592) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(593) : error C2143: syntax error : missing ';' before '++'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(593) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(593) : error C2086: 'int *p' : redefinition
1> c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(568) : see declaration of 'p'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(641) : error C2297: '*' : illegal, right operand has type 'float *'
1>c:\_src\directxsamples\ex_tut2_showjpg\tut2_vertices.cpp(641) : error C2017: illegal escape sequence
看起来你的帖子大部分是代码,请添加更多细节
以下是我如何使用它:
float* p = (float*)malloc(999);
fill(i_im_x, i_im_x + 512.0f,
i_im_y, i_im_y + 512.0f,
0.0f, 1.0f,
0.0f, 1.0f);
您需要这样做:
///xx
注释替换为/*xx*/
\
后的多余空格字符:这并不明显,因为除非将光标放在那里,否则无法看到该偏移空间
\
:工作示例:
#define fill(where_l, where_r, where_t, where_b, what_l, what_r, what_t, what_b) \
\
/*lt*/ \
*p++ = where_l; \
*p++ = where_t; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_l; \
*p++ = what_t; \
\
/* rt */ \
*p++ = where_r; \
*p++ = where_t; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_r; \
*p++ = what_t; \
\
/*lb*/ \
*p++ = where_l; \
*p++ = where_b; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_l; \
*p++ = what_b; \
\
/*rb*/ \
*p++ = where_r; \
*p++ = where_b; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_r; \
*p++ = what_b;
int main(int argc, char **argv) {
float* p = (float*)malloc(999);
fill(1, 2, 3, 4, 5, 6, 7, 8)
}
my ide中的语法突出显示是错误的。如果曾经有一个宏应该是函数…将所有
///lt
替换为/*lt*///code>,宏将正常。请说明如何使用填充宏,问题可能就在那里。请阅读:宏以“\”结尾,也就是说,接下来的任何内容都是宏的一部分。这非常有帮助。找到原因,在/
之后有空格。
*p++ = what_b; \
^ remove this
#define fill(where_l, where_r, where_t, where_b, what_l, what_r, what_t, what_b) \
\
/*lt*/ \
*p++ = where_l; \
*p++ = where_t; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_l; \
*p++ = what_t; \
\
/* rt */ \
*p++ = where_r; \
*p++ = where_t; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_r; \
*p++ = what_t; \
\
/*lb*/ \
*p++ = where_l; \
*p++ = where_b; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_l; \
*p++ = what_b; \
\
/*rb*/ \
*p++ = where_r; \
*p++ = where_b; \
*p++ = 0.5f; \
*p++ = 1.0f; \
*p++ = what_r; \
*p++ = what_b;
int main(int argc, char **argv) {
float* p = (float*)malloc(999);
fill(1, 2, 3, 4, 5, 6, 7, 8)
}