简体   繁体   English

将旧式C ++标准库从GNU版本迁移到LLVM中的库

[英]Moving legacy C++ standard library from GNU version to that in LLVM

I have a Mac app which is built with the Nano library, which is no longer being developed. 我有一个用Nano库构建的Mac应用程序,该库不再开发。 It uses the GNU standard C++ library, but that is not usable with Xcode 10 or later, so I'm trying to update the bits that need it to work with the version built into LLVM. 它使用GNU标准C ++库,但是在Xcode 10或更高版本中不可用,因此我试图更新需要它的位才能与LLVM内置的版本一起使用。

I've managed to solve some issues, but there is a problem with functors. 我已经设法解决了一些问题,但是函子存在问题。

In the base class for functors, NFunctor, there are various macros so that the class is defined as: 在函子的基类NFunctor中,有各种宏,因此将该类定义为:

typedef nfunctor<void (void)>   NFunctor;

That ends up (I think, as preprocessing fails) as: 最终(我认为,由于预处理失败)如下:

typedef std::function<void (void)> NFunctor;

In the original code, it came out as: 在原始代码中,结果为:

typedef std::tr1::function<void (void)> NFunctor;

Compiling fails with an error: 编译失败并显示错误:

error: no template named 'function' in namespace 'std' 错误:名称空间“ std”中没有名为“功能”的模板

In the GNU library, there's a definition: 在GNU库中,有一个定义:

 template<typename _Signature>
    class function;

In the standard library, there's 在标准库中,

template<class _Fp> class _LIBCPP_TEMPLATE_VIS function; // undefined

but also 但是也

template<class _Rp, class ..._ArgTypes>
class _LIBCPP_TEMPLATE_VIS function<_Rp(_ArgTypes...)>
    : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
      public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)>

Further, looking at the Wikipedia page Functional(C++), it has an example: 此外,查看Wikipedia页面Functional(C ++),它有一个示例:

  /* A function wrapper generated by std::bind().
   * Pass a pre-defined parameter when binding.
   */
  std::function<void(void)> func_d = std::bind(PrintValue<std::string>, "PI is");
  func_d();

which looks like what I'm aiming to produce. 看起来就像我要生产的。

So my eventual question is what should be done to replace the old TR1 version of function in this code? 因此,我的最终问题是,在此代码中应该怎么做才能替换旧的TR1版本的函数?

It turned out to be a matter of compiler settings. 事实证明,这与编译器设置有关。 Setting the language dialect to C++14 or C++17 (or the GNU variants) seems to have fixed things. 将语言方言设置为C ++ 14或C ++ 17(或GNU变体)似乎有固定的东西。

I've got past problems with the standard library, and now I'll have to deal with other questions as they arise (still not completely working). 我在使用标准库时遇到了一些问题,现在我不得不处理其他问题(它们仍然无法完全正常工作)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 传统的标准C库头文件和重载的C ++函数 - Legacy standard C library headers and overloaded C++ functions LLVM C ++和GNU C ++的标准库具有不同的头 - Standard libraries of LLVM C++ and GNU C++ have different headers 使用哪种算法在GNU C ++标准库中计算指数函数? - With which algorithm exponential functions are computed in the GNU C++ Standard Library? C ++库交叉依赖关系-从llvm移植到gcc - C++ library cross dependencies - porting from llvm to gcc 从C ++中的嵌入式LLVM生成二进制代码(共享库) - Generate binary code (shared library) from embedded LLVM in C++ 在.mm文件中找到的C ++标准库,在.h文件中找不到(Xcode 4.5 LLVM GCC 4.2) - C++ Standard Library found in .mm files but not in the .h (Xcode 4.5 LLVM GCC 4.2) 根据C ++语言版本和标准库依赖性提升需求 - Boost requirements in terms of C++ language version and Standard Library dependencies Gnu C ++宏__cplusplus标准符合? - Gnu C++ macro __cplusplus standard conform? 在哪里可以将源代码下载到GNU C ++标准库? - Where can I download the source code to the GNU C++ Standard Library? 在C ++应用程序中使用C库的标准输出 - Using standard output from C library in C++ application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM