我试图在C ++中声明一个回调例程,如下所示:
void register_rename (int (*function) (const char *current, const char *new));
/*------------------------------------------------------------*/
/* WHEN: The callback is called once each time a file is received and
* accepted. (Renames the temporary file to its permanent name)
* WHAT: Renames a file from the given current name to the specified new name.
*/
但是,我收到以下错误:
line 204: error #70:
incomplete type is not allowed
void register_rename (int (*function) (const char *current, const char *new));
我不确定如何纠正这个问题。我在同一个头文件中声明了其他类似的回调例程,我没有收到此错误。
请帮忙! :)
答案 0 :(得分:19)
您不能使用new,因为它是关键字。尝试为第二个参数选择一个有效的标识符。
答案 1 :(得分:7)
您不能使用保留字命名变量(或任何标识符);
保留字是关键字
asm do if return try
auto double inline short typedef
bool dynamic_cast int signed typeid
break else long sizeof typename
case enum mutable static union
catch explicit namespace static_assert unsigned
char export **new** static_cast using
class extern operator struct virtual
const false private switch void
const_cast float protected template volatile
continue for public this wchar_t
default friend register throw while
delete goto reinterpret_cast true
和一些运营商的替代名称
and and_eq bitand bitor compl not
not_eq or or_eq xor xor_eq