在阅读了一些有关 FastFormat 的内容后,我决定将其下载并安装到我运行 OS X 10.8 的 Macbook Pro 上。我成功地构建了 FastFormat,并运行了性能测试。然后我写了一个小测试来检查它是否有效:
#include <cstdlib>
#include <fastformat/fastformat.hpp>
#include <fastformat/sinks/ostream.hpp>
int main()
{
return EXIT_SUCCESS;
}
在使用 g++-4.7 编译它(并确保所有包含路径都是正确的)后,我从 PlatformSTL 得到了编译时错误,如下所示。
error: #error Operating system not discriminated. Only UNIX and Windows are currently recognised by PlatformSTL
error: #error Operating system not discriminated
我试图通过手动定义 unix
和 PLATFORMSTL_OS_IS_UNIX
来抑制这些错误,但随后我收到了这些链接器错误:
Undefined symbols for architecture x86_64:
"_fastformat_exitProcess", referenced from:
fastformat::fastformat_initialiser::fastformat_initialiser() in ccMqErni.o
"_fastformat_getInitCodeString", referenced from:
fastformat::fastformat_initialiser::record_init_failure_(int) in ccMqErni.o
"_fastformat_init", referenced from:
fastformat::fastformat_initialiser::fastformat_initialiser() in ccMqErni.o
"_fastformat_uninit", referenced from:
fastformat::fastformat_initialiser::~fastformat_initialiser() in ccMqErni.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status
OS X 是否支持 FastFormat,如果支持,我做错了什么?
最佳答案
Mac OS X 不提供 UNIX
(或 unix
, __unix__
, __unix
)宏 PlatformSTL
试图检测。添加 defined(__MACH__)
行后,我能够编译您的示例platformstl.h
中的声明像这样(第 154 行):
#if defined(unix) || \
defined(UNIX) || \
defined(__unix__) || \
defined(__unix) || \
defined(__MACH__)
# define PLATFORMSTL_OS_IS_UNIX
要抑制 undefined symbol 错误,您可以定义宏 FASTFORMAT_NO_AUTO_INIT
:
g++ -I<path to fastformat and stlsoft headers> -DFASTFORMAT_NO_AUTO_INIT main.cpp
关于c++ - OS X 上的快速格式化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13717936/