Fixed compiler errors on Apple due to cross product of {C++03,C++11} x {libc++, libstdc++}. It included bringing in the correct <memory> in <stdcpp.h>, and then only including <stdcpp.h> when <memory> was needed.

pull/35/head
Jeffrey Walton 2015-07-27 16:01:55 -04:00
parent 418dd2a870
commit ef318d5423
8 changed files with 40 additions and 25 deletions

View File

@ -6,6 +6,8 @@
#include "cryptlib.h" #include "cryptlib.h"
#include "misc.h" #include "misc.h"
#include "stdcpp.h"
#include "smartptr.h"
#include "filters.h" #include "filters.h"
#include "algparam.h" #include "algparam.h"
#include "fips140.h" #include "fips140.h"
@ -15,8 +17,6 @@
#include "osrng.h" #include "osrng.h"
#include "trap.h" #include "trap.h"
#include <memory>
#if GCC_DIAGNOSTIC_AWARE #if GCC_DIAGNOSTIC_AWARE
# pragma GCC diagnostic ignored "-Wunused-value" # pragma GCC diagnostic ignored "-Wunused-value"
# pragma GCC diagnostic ignored "-Wunused-variable" # pragma GCC diagnostic ignored "-Wunused-variable"

View File

@ -8,8 +8,8 @@
#include "queue.h" #include "queue.h"
#include "validate.h" #include "validate.h"
#include "trap.h" #include "trap.h"
#include <iostream> #include <iostream>
#include <memory>
USING_NAMESPACE(CryptoPP) USING_NAMESPACE(CryptoPP)
USING_NAMESPACE(std) USING_NAMESPACE(std)

View File

@ -2,9 +2,10 @@
#include "pch.h" #include "pch.h"
#include "default.h" #include "default.h"
#include "stdcpp.h"
#include "queue.h" #include "queue.h"
#include <time.h> #include <time.h>
#include <memory>
#if GCC_DIAGNOSTIC_AWARE #if GCC_DIAGNOSTIC_AWARE
# pragma GCC diagnostic ignored "-Wunused-value" # pragma GCC diagnostic ignored "-Wunused-value"

View File

@ -8,11 +8,9 @@
#include "mqueue.h" #include "mqueue.h"
#include "fltrimpl.h" #include "fltrimpl.h"
#include "argnames.h" #include "argnames.h"
#include "stdcpp.h"
#include "trap.h" #include "trap.h"
#include <memory>
#include <functional>
#if GCC_DIAGNOSTIC_AWARE #if GCC_DIAGNOSTIC_AWARE
# pragma GCC diagnostic ignored "-Wunused-value" # pragma GCC diagnostic ignored "-Wunused-value"
# pragma GCC diagnostic ignored "-Wunused-variable" # pragma GCC diagnostic ignored "-Wunused-variable"

6
misc.h
View File

@ -3,13 +3,9 @@
#include "cryptlib.h" #include "cryptlib.h"
#include "smartptr.h" #include "smartptr.h"
#include "stdcpp.h"
#include "trap.h" #include "trap.h"
#include <cstring> // for memcpy and memmove
#include <cstddef> // for size_t when -stdlib=libc++
#include <iosfwd> // for std::streamsize
#include <limits> // for std::numeric_limits
#ifdef _MSC_VER #ifdef _MSC_VER
#if _MSC_VER >= 1400 #if _MSC_VER >= 1400
// VC2005 workaround: disable declarations that conflict with winnt.h // VC2005 workaround: disable declarations that conflict with winnt.h

View File

@ -37,10 +37,9 @@
#include "eprecomp.h" #include "eprecomp.h"
#include "fips140.h" #include "fips140.h"
#include "argnames.h" #include "argnames.h"
#include "stdcpp.h"
#include "trap.h" #include "trap.h"
#include <memory>
// VC60 workaround: this macro is defined in shlobj.h and conflicts with a template parameter used in this file // VC60 workaround: this macro is defined in shlobj.h and conflicts with a template parameter used in this file
#undef INTERFACE #undef INTERFACE

View File

@ -11,17 +11,31 @@
#include <limits.h> #include <limits.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
// http://marshall.calepin.co/c-and-xcode-46.html. LLVM places unique_ptr in std:: when using
// using -stdlib=libc++ (and not std::tr1::) regardless of C++03/C++11. We detect can detect
// it with _LIBCPP_VERSION, but its not accurate because Apple's built-in Clang behaves
// differently than a LLVM downloaded and compiled CLang. So we fall back to Clang's
// __has_include (http://clang.llvm.org/docs/LanguageExtensions.html#id3).
#if (__cplusplus >= 201103L) && !defined(__clang__)
# include <memory> # include <memory>
#elif defined(__clang__)
# if (__has_include(<tr1/memory>))
# include <tr1/memory>
# endif
#elif (__cplusplus < 201103L)
# include <tr1/memory>
#else
# include <memory>
#endif
#include <map>
#include <vector>
#include <string> #include <string>
#include <exception> #include <exception>
#include <typeinfo> #include <typeinfo>
#include <algorithm> #include <algorithm>
#include <map> #include <functional>
#include <vector>
#if !defined(_NDEBUG) && !defined(NDEBUG)
# include <cassert>
#endif
#ifdef CRYPTOPP_INCLUDE_VECTOR_CC #ifdef CRYPTOPP_INCLUDE_VECTOR_CC
// workaround needed on Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21 // workaround needed on Sun Studio 12u1 Sun C++ 5.10 SunOS_i386 128229-02 2009/09/21
@ -29,9 +43,16 @@
#endif #endif
// for alloca // for alloca
#ifdef __sun // #ifdef __sun
// #include <alloca.h>
// #elif defined(__MINGW32__) || defined(__BORLANDC__)
// #include <malloc.h>
// #endif
// Rijdael uses alloca. Just include it for everyone....
#include <alloca.h> #include <alloca.h>
#elif defined(__MINGW32__) || defined(__BORLANDC__)
#if defined(__MINGW32__) || defined(__BORLANDC__)
# include <malloc.h> # include <malloc.h>
#endif #endif

View File

@ -3,6 +3,7 @@
#include "pch.h" #include "pch.h"
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 #define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
#include "stdcpp.h"
#include "files.h" #include "files.h"
#include "misc.h" #include "misc.h"
#include "hex.h" #include "hex.h"
@ -39,7 +40,6 @@
#include "trap.h" #include "trap.h"
#include <time.h> #include <time.h>
#include <memory>
#include <iostream> #include <iostream>
#include <iomanip> #include <iomanip>