FastFormat on OS X

Question

After reading a little about FastFormat, I decided to download and install it on my Macbook Pro, running OS X 10.8. I successfully got FastFormat to build, and ran the performance tests. Then I wrote a small test to check whether it works:

#include <cstdlib>
#include <fastformat/fastformat.hpp>
#include <fastformat/sinks/ostream.hpp>

int main()
{
    return EXIT_SUCCESS;
}

Upon compiling it with g -4.7 (and making sure that all the include paths were correct), I got compile-time errors, such as the ones below, from PlatformSTL.

error: #error Operating system not discriminated. Only UNIX and Windows are currently recognised by PlatformSTL
error: #error Operating system not discriminated

I tried to suppress these errors by defining unix and PLATFORMSTL_OS_IS_UNIX manually, but I then receive these linker errors:

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

Is FastFormat supported on OS X, and if so, what am I doing wrong?

Solution

Mac OS X does not provide UNIX (or unix, __unix__, __unix) macro which PlatformSTL tries to detect. I was able to compile your example after adding the line defined(__MACH__) statement in platformstl.h like this (line 154):

#if defined(unix) || \ 
    defined(UNIX) || \ 
    defined(__unix__) || \ 
    defined(__unix) || \ 
    defined(__MACH__) 
# define PLATFORMSTL_OS_IS_UNIX

To supress the undefined symbols error you can define macro FASTFORMAT_NO_AUTO_INIT:

g -I<path to fastformat and stlsoft headers> -DFASTFORMAT_NO_AUTO_INIT main.cpp