所以,我有一个函数指针定义为:
unsigned static int (*current_hash_function)(unsigned int);
我正在尝试制作指向函数名称的指针映射:
typedef std::map<fptr_t, std::string> function_map_t;
但是我得到这个错误:
src/main.h:24: error: ISO C++ forbids declaration of
‘fptr_t’
with no type
其他代码:
main.h:
typedef (*fptr_t)(unsigned int*);
typedef std::map<fptr_t, std::string> function_map_t;
function_map_t fmap;
最佳答案
您的“main.h”代码没有为函数指针 typedef 提供返回类型。这对我有用:
#include <map>
#include <string>
int main()
{
typedef unsigned (*fptr_t)(unsigned);
typedef std::map<fptr_t, std::string> function_map_t;
function_map_t fmap;
}
关于C++:我使用什么类型来定义这个映射?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5955325/