mac下使用hash_map头文件的方法

本文提供了一个使用GCC扩展库中的hash_map的示例代码。该示例展示了如何根据编译器的不同选择包含不同的头文件,并使用hash_map进行基本操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

#if defined __GNUC__ || defined __APPLE__
#include <ext/hash_map>
#else
#include <hash_map>
#endif

int main()
{
        using namespace __gnu_cxx;

        hash_map<int, int> map;
}
/root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:29:5: error: type name requires a specifier or qualifier __uint(type, BPF_MAP_TYPE_HASH); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:29:12: error: a parameter list without types is only allowed in a function definition __uint(type, BPF_MAP_TYPE_HASH); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:30:5: error: type name requires a specifier or qualifier __uint(max_entries, 1024); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:30:25: error: expected identifier __uint(max_entries, 1024); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:30:5: error: duplicate member '__uint' __uint(max_entries, 1024); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:29:5: note: previous declaration is here __uint(type, BPF_MAP_TYPE_HASH); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:31:5: error: type name requires a specifier or qualifier __type(key, struct flow_key); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:31:17: error: expected identifier __type(key, struct flow_key); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:32:5: error: type name requires a specifier or qualifier __type(value, __u8); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:32:19: error: unexpected type name '__u8': expected identifier __type(value, __u8); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:32:12: error: a parameter list without types is only allowed in a function definition __type(value, __u8); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:32:5: error: duplicate member '__type' __type(value, __u8); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:31:5: note: previous declaration is here __type(key, struct flow_key); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:37:5: error: type name requires a specifier or qualifier __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); ^ /root/bpf/linux-4.19.90/samples/bpf/xdp_whitelist_kern.c:37:12: error: a parameter list without types is only allowed in a function definition __uint(type, BPF_MAP_TYPE_PERF_EVENT_ARRAY); ^ 16 errors generated.
07-22
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值