Compiling FastFlow Library on Windows with Visual Studio 2013 (Express)

The latest version of FastFlow suffers heavily from compiler errors if you try to build it with Visual Studio 2013 version.

If you are willing to modify this efficient stream processing C++ library code in few places as indicated below, you should be able to get started using the library in under five minutes compiled with Visual Studio.

As a first step, you can get the latest version of FastFlow source code from here.

Here are the modifications, to get started:

  1. In CMakeLists.txt file at line 66 and 70, update the Windows version to be:
    • D_WIN32_WINNT=0x0601
  2. In spin-lock.hpp file, at line 196, comment the pre-processor HAS_CXX11_VARIADIC_TEMPLATES condition:
    • /*|| (defined(HAS_CXX11_VARIADIC_TEMPLATES))*/
  3. In mapping_utils.hpp file, at line 174, correct the #warning to be:
    • #pragma message("ff_realNumCores not supported on this platform")
  4. In mapping_utils.hpp file, at line 194, correct the #warning to be:
    • #pragma message("ff_numSockets not supported on this platform")
  5. In node.hpp file, at line 63, add _WIN32 preprocessor condition:
    • #if defined(__APPLE__) ||defined _WIN32
  6. In platforms/platform.h, at line 206, add the definition for ssize_t:
    • #include <BaseTsd.h>
      typedef SSIZE_T ssize_t;
  7. In farm.hpp at line 32, add:
    • #include <ff/config.hpp>

After these modifications you are in pretty good shape to start compiling the examples. Most of them succeed, and it should be enough for many.

However, for few examples and tests that involve parallel_for.hpp, you may still see few errors regarding std::atomic_long initialization. A quick fix solution requires you to replace all std::atomic_long declarations with std::atomic<long>. Another solution would be replace the atomic_long initializations in the constructor with operator= (assignment operator). For some reason, the Visual Studio definition of std::atomic_long (and its peers) does not have constructor, instead it provides std::atomic (though with an _ATOMIC_HAS_NO_SPECIALIZATION conditional #ifndef).

Rather the right way, as noted above, for the std::atomic_long is to use assignment operator for the initialization. Perhaps this is to avoid accidental boxing/up-gradation of atomic variables from their corresponding native types. Though an explicit constructor is much preferred than no-constructor and assignment operator combination.