Skip to content

Commit

Permalink
remove experimental C++14 usage and disable its support for ABI compa…
Browse files Browse the repository at this point in the history
…tibility
  • Loading branch information
sytelus committed Jul 22, 2017
1 parent e43efd0 commit 77837fc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
13 changes: 5 additions & 8 deletions MavLinkCom/MavLinkTest/Commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@
#include "FileSystem.hpp"
#include "Utils.hpp"

#if defined(_WIN32)
#if defined(_WIN32) || ((defined __cplusplus) && (__cplusplus >= 201700L))
#include <filesystem>
// for some unknown reason, VC++ doesn't define this handy macro...
#define __cpp_lib_experimental_filesystem 201406
#define USE_CPP_FILESYSTEM
#else
#if __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
#endif
#undef USE_CPP_FILESYSTEM
#endif


Expand Down Expand Up @@ -470,8 +467,8 @@ void DumpLogCommandsCommand::Execute(std::shared_ptr<MavLinkVehicle> com)
{
unused(com);
//TODO: make below future proof (i.e. usable by C++17 compiler) - also change same in main.cpp
#if defined(__cpp_lib_experimental_filesystem)
using namespace std::experimental::filesystem::v1;
#if defined(USE_CPP_FILESYSTEM)
using namespace std::filesystem;
path dirPath(log_folder_);

for (directory_iterator next(dirPath), end; next != end; ++next) {
Expand Down
17 changes: 7 additions & 10 deletions MavLinkCom/MavLinkTest/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ STRICT_MODE_OFF
STRICT_MODE_ON
#include "UnitTests.h"

#if defined(_WIN32)
#if defined(_WIN32) || ((defined __cplusplus) && (__cplusplus >= 201700L))
#include <filesystem>
// for some unknown reason, VC++ doesn't define this handy macro...
#define __cpp_lib_experimental_filesystem 201406
#define USE_CPP_FILESYSTEM
#else
#if __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
#endif
#undef USE_CPP_FILESYSTEM
#endif

/* enable math defines on Windows */
Expand Down Expand Up @@ -156,9 +153,9 @@ std::shared_ptr<MavLinkConnection> logConnection;
std::shared_ptr<MavLinkVehicle> mavLinkVehicle;


#if defined(__cpp_lib_experimental_filesystem)
#if defined(USE_CPP_FILESYSTEM)

using namespace std::experimental::filesystem::v1;
using namespace std::filesystem;

void ConvertLogFileToJson(std::string logFile)
{
Expand Down Expand Up @@ -900,7 +897,7 @@ bool ParseCommandLine(int argc, const char* argv[])
}
}
}
#if defined(__cpp_lib_experimental_filesystem)
#if defined(USE_CPP_FILESYSTEM)
else if (lower == initOption) {

if (parts.size() > 1)
Expand Down Expand Up @@ -1473,7 +1470,7 @@ int main(int argc, const char* argv[])
return 1;
}

#if defined(__cpp_lib_experimental_filesystem)
#if defined(USE_CPP_FILESYSTEM)
if (convertExisting) {
if (jsonLogFormat) {
ConvertLogFilesToJson(logDirectory);
Expand Down
4 changes: 3 additions & 1 deletion cmake/cmake-modules/CommonSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ macro(CommonSetup)
set(CMAKE_EXE_LINKER_FLAGS "\
${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi -lm -lc -lgcc_s -lgcc -ldl \
-L ${LIBCXX_LIB_PATH}")
set(CXX_EXP_LIB "-lc++experimental")

#do not use experimental as it might potentially cause ABI issues
#set(CXX_EXP_LIB "-lc++experimental")

if("${BUILD_TYPE}" STREQUAL "debug")
# set same options that Unreal sets in debug builds
Expand Down
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export C_COMPILER=clang-3.9
export COMPILER=clang++-3.9

cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \
-DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON \
-LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY=OFF -DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=OFF \
-DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=./output \
../llvm-source

Expand Down

0 comments on commit 77837fc

Please sign in to comment.