std::bind 不与 lua_call 相互操作

在使用 Lua 5.3.5 和 gcc 9.2.0 的开发库时,我遇到了以下最小代码片段的奇怪编译问题:

#include <functional>

extern "C" {
  #include "lua.h"
  #include "lualib.h"
}

int main()
{
  using namespace std::placeholders;

  auto lua_simple_call = std::bind(lua_call, _1, 0, 0);
}

gcc 抱怨:error: ‘lua_call’ was not declared in this scope。当尝试简单调用 lua_call 而没有使用 std::bind 时,不会出现此问题,也似乎不会出现对其他 Lua C 函数(如 lua_newtable 等)的影响。我想知道这是什么原因以及如何避免它。

点赞