Skip to content

Commit

Permalink
Enable C++0x support
Browse files Browse the repository at this point in the history
We need C++0x features enabled for "auto" to work, and using Boost properly
seems to require this. Use "auto" in a few places to prove that it works.
  • Loading branch information
qris committed Jul 27, 2017
1 parent 76f8199 commit 421a3d9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
3 changes: 3 additions & 0 deletions infrastructure/cmake/CMakeLists.txt
Expand Up @@ -754,6 +754,9 @@ file(TO_NATIVE_PATH "${PERL_EXECUTABLE}" perl_executable_native)
string(REPLACE "\\" "\\\\" perl_path_escaped ${perl_executable_native})
target_compile_definitions(test_backupstorefix PRIVATE -DPERL_EXECUTABLE="${perl_path_escaped}")

target_compile_features(lib_httpserver PRIVATE cxx_auto_type)
target_compile_features(lib_backupstore PRIVATE cxx_auto_type)

# Configure test timeouts:
# I've set the timeout to 4 times as long as it took to run on a particular run on Appveyor:
# https://ci.appveyor.com/project/qris/boxbackup/build/job/xm10itascygtu93j
Expand Down
11 changes: 10 additions & 1 deletion infrastructure/m4/boxbackup_tests.m4
Expand Up @@ -30,7 +30,16 @@ BOX_CHECK_CXX_FLAG(-Werror=delete-non-virtual-dtor)
# This error is detected by MSVC, but not usually by GCC/Clang:
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58114
BOX_CHECK_CXX_FLAG(-Werror=delete-incomplete)

# Using Boost properly seems to need C++0x, or at least the "auto" type.
# We don't need CMake to parse this, because it has built-in feature detecting macros
# which we use instead:
AX_CHECK_COMPILE_FLAG(-std=c++0x,
[cxxflags_strict="$cxxflags_strict -std=c++0x"])
# And if we're going to do that, we don't want warnings about std::auto_ptr being deprecated:
BOX_CHECK_CXX_FLAG(-Wno-deprecated-declarations)
# We also get copious warnings from the 'register' storage class specifier in the system
# headers (ntohl and friends) which we can't do much about, so disable it:
BOX_CHECK_CXX_FLAG(-Wno-deprecated-register)
AC_SUBST([CXXFLAGS_STRICT], [$cxxflags_strict])

if test "x$GXX" = "xyes"; then
Expand Down
7 changes: 3 additions & 4 deletions lib/backupstore/BackupStoreContext.cpp
Expand Up @@ -94,8 +94,7 @@ BackupStoreContext::~BackupStoreContext()
void BackupStoreContext::ClearDirectoryCache()
{
// Delete the objects in the cache
for(std::map<int64_t, BackupStoreDirectory*>::iterator i(mDirectoryCache.begin());
i != mDirectoryCache.end(); ++i)
for(auto i(mDirectoryCache.begin()); i != mDirectoryCache.end(); ++i)
{
delete (i->second);
}
Expand Down Expand Up @@ -311,7 +310,7 @@ BackupStoreDirectory &BackupStoreContext::GetDirectoryInternal(int64_t ObjectID,
int64_t oldRevID = 0, newRevID = 0;

// Already in cache?
std::map<int64_t, BackupStoreDirectory*>::iterator item(mDirectoryCache.find(ObjectID));
auto item = mDirectoryCache.find(ObjectID);
if(item != mDirectoryCache.end())
{
#ifndef BOX_RELEASE_BUILD // it might be in the cache, but invalidated
Expand Down Expand Up @@ -986,7 +985,7 @@ bool BackupStoreContext::UndeleteFile(int64_t ObjectID, int64_t InDirectory)
// --------------------------------------------------------------------------
void BackupStoreContext::RemoveDirectoryFromCache(int64_t ObjectID)
{
std::map<int64_t, BackupStoreDirectory*>::iterator item(mDirectoryCache.find(ObjectID));
auto item = mDirectoryCache.find(ObjectID);
if(item != mDirectoryCache.end())
{
// Delete this cached object
Expand Down

0 comments on commit 421a3d9

Please sign in to comment.