【问题标题】:xtables_find_match in g++ does not work but it is fine in gccg++ 中的 xtables_find_match 不起作用,但在 gcc 中没问题
【发布时间】:2015-02-21 22:58:58
【问题描述】:

Iptables 是一个 c 实现的库。

我的项目是基于C++的,所以我新建了一个头文件h1.h,它将通过'extern "c"{#include h1.h}'包含在我的c++文件中。

许多 iptables-lib 函数在我的 c++ 项目中都可以正常工作,除了 do_command() 中的 xtables_find_match()。

================================

gcc -c -std=c99 -o file1.o file1.c
g++ -c -std=c++0x -o file2.o file2.cpp
g++ -o myapp file1.o file2.o

【问题讨论】:

  • 在什么方面不起作用?是否存在编译器/链接器错误?程序会崩溃吗?怎么调用函数?
  • 应该是extern "C",大写为C。

标签: c++ iptables


【解决方案1】:

应首先调用 xtables_init_all 和 init_extensions 等函数。 否则 load_extension 将静默退出。

xtables_find_match 将调用 load_extension。

【讨论】:

    猜你喜欢
    • 2010-09-25
    • 1970-01-01
    • 2021-12-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-11-09
    • 2021-07-07
    • 2020-02-26
    相关资源
    最近更新 更多