c++ - 函数指针声明在 C 中有效,但在 C++ 中无效

标签 c++ c++11 function-pointers

所以我目前正在将一个小型 C 库导入到一个新的空 C++ 项目中,但它根本无法编译。它用 C 编译它工作得很好,但它根本不适用于 C++。我唯一要做的就是包含标题。

这似乎是语法错误,但也可能是其他原因。这是编译器唯一唠叨的事情:

error: expected unqualified-id before 'export'
bool (*export)(struct wld_exporter * exporter, struct wld_buffer * buffer, uint32_t type, union wld_object * object);
error: expected ')' before 'export'

因为我认为这是一个语法问题,所以我只是不知道该怎么做并尝试了一些愚蠢的事情,比如在导出后移动星号而不是事先希望它会起作用,但显然没有。

我不知道为什么编译器不能识别它应该是一个函数指针,我之前在 c++ 中完成函数指针 c-style 没有任何问题。

如果有任何区别,我正在使用 gcc 和 C++11。

最佳答案

export 是 C++ 中的关键字,不能将其用作标识符。

此处的关键字列表:C++ keywords

关于c++ - 函数指针声明在 C 中有效,但在 C++ 中无效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29048985/

相关文章:

c++ - 外部内联函数 gcc

c++ - MySql 和 SQL Server 备份代码

c++ - C++ 中 "array of unknown bound of T"的外部声明

c++ - `constexpr` `std::array` 的二元运算

c - 夹板警告 "Statement has no effect"由于函数指针

c++ - 函数指针生成 'invalid use of non-static member function' 错误

C++修改对象指针指向但不保留值

c++ - 错误 : 'CLOCK_MONOTONIC' undeclared (first use in this function)

c++ - 3d vector - 变换和减去

c++ - 默认纯虚析构函数