From 0ddcff0b07566260e1e00990f70555110fb5cfa7 Mon Sep 17 00:00:00 2001 From: Alex Zolotarev Date: Tue, 14 Oct 2014 02:14:55 -0700 Subject: [PATCH] [msvc][win] Fixed compilation issues --- 3party/3party.pro | 5 +- .../filesystem/src/windows_file_codecvt.hpp | 56 +++++++++++ 3party/fribidi/fribidi.pro | 2 +- 3party/fribidi/lib/common.h | 2 +- 3party/fribidi/lib/fribidi-common.h | 2 +- 3party/gflags/src/gflags/gflags.h | 5 +- 3party/gmock/gmock.pro | 2 +- 3party/jansson/src/jansson_config.h | 2 +- 3party/osrm/osrm.pro | 2 +- .../protobuf/io/zero_copy_stream_impl_lite.cc | 2 + anim/controller.cpp | 8 +- anim/task.cpp | 2 +- base/commands_queue.cpp | 2 +- base/condition_windows_native.cpp | 6 ++ base/internal/fast_mutex.hpp | 2 +- base/resource_pool.hpp | 8 +- base/shared_buffer_manager.cpp | 1 - base/thread.cpp | 4 +- base/thread_pool.cpp | 2 +- base/timer.cpp | 2 +- coding/coding.pro | 5 +- coding/coding_tests/file_container_test.cpp | 7 +- coding/file_container.cpp | 8 ++ coding/parse_xml.hpp | 4 +- common.pri | 25 ++--- drape/drape.pro | 2 + drape/drape_tests/compile_shaders_test.cpp | 14 +-- drape/drape_tests/drape_tests.pro | 7 +- drape/glIncludes.hpp | 5 + drape/glfunctions.cpp | 97 ++++++++++--------- drape/symbols_texture.cpp | 2 +- drape_frontend/frontend_renderer.cpp | 6 +- drape_frontend/read_manager.cpp | 6 ++ drape_head/drape_head.pro | 4 +- drape_head/testing_engine.cpp | 19 ++-- generator/borders_loader.cpp | 6 +- generator/generator.pro | 2 +- generator/generator_tests/generator_tests.pro | 2 + generator/osm_element.hpp | 2 +- geometry/region2d/binary_operators.cpp | 4 +- graphics/graphics.pro | 5 +- graphics/opengl/gl_procedures.inl | 1 - graphics/opengl/opengl_win32.cpp | 3 + graphics/packets_queue.hpp | 4 +- indexer/index.hpp | 2 +- map/active_maps_layout.cpp | 14 +-- map/country_status_display.cpp | 6 +- map/coverage_generator.cpp | 10 +- map/information_display.cpp | 4 +- map/map.pro | 7 +- map/queued_renderer.cpp | 29 +++--- map/track.cpp | 4 +- map_server/map_server.pro | 1 + platform/platform_win.cpp | 2 +- qt/mainwindow.cpp | 4 +- routing/osrm2feature_map.cpp | 2 +- routing/osrm2feature_map.hpp | 2 +- routing/osrm_router.cpp | 5 +- routing/routing_tests/routing_tests.pro | 5 +- search/indexed_value.hpp | 2 +- std/algorithm.hpp | 46 +++++++++ std/bind.hpp | 2 +- std/common_defines.hpp | 6 ++ std/function.hpp | 2 +- std/shared_ptr.hpp | 2 +- std/systime.hpp | 4 + std/unordered_map.hpp | 5 - std/unordered_set.hpp | 5 - std/weak_ptr.hpp | 2 +- std/windows.hpp | 29 +----- storage/storage_tests/storage_tests.pro | 2 +- 71 files changed, 336 insertions(+), 225 deletions(-) create mode 100644 3party/boost/libs/filesystem/src/windows_file_codecvt.hpp diff --git a/3party/3party.pro b/3party/3party.pro index 915c75073b..c84d19a984 100644 --- a/3party/3party.pro +++ b/3party/3party.pro @@ -2,10 +2,7 @@ TEMPLATE = subdirs -SUBDIRS = freetype fribidi zlib bzip2 jansson tomcrypt protobuf osrm - -# use expat from the system on linux -!linux*: SUBDIRS *= expat +SUBDIRS = freetype fribidi zlib bzip2 jansson tomcrypt protobuf osrm expat !iphone*:!tizen*:!android* { SUBDIRS += gflags \ diff --git a/3party/boost/libs/filesystem/src/windows_file_codecvt.hpp b/3party/boost/libs/filesystem/src/windows_file_codecvt.hpp new file mode 100644 index 0000000000..53ff149f47 --- /dev/null +++ b/3party/boost/libs/filesystem/src/windows_file_codecvt.hpp @@ -0,0 +1,56 @@ +// filesystem windows_file_codecvt.hpp -----------------------------------------------// + +// Copyright Beman Dawes 2009 + +// Distributed under the Boost Software License, Version 1.0. +// See http://www.boost.org/LICENSE_1_0.txt + +// Library home page: http://www.boost.org/libs/filesystem + +#ifndef BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP +#define BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP + +#include +#include + + //------------------------------------------------------------------------------------// + // // + // class windows_file_codecvt // + // // + // Warning: partial implementation; even do_in and do_out only partially meet the // + // standard library specifications as the "to" buffer must hold the entire result. // + // // + //------------------------------------------------------------------------------------// + + class BOOST_FILESYSTEM_DECL windows_file_codecvt + : public std::codecvt< wchar_t, char, std::mbstate_t > + { + public: + explicit windows_file_codecvt() + : std::codecvt() {} + protected: + + virtual bool do_always_noconv() const throw() { return false; } + + // seems safest to assume variable number of characters since we don't + // actually know what codepage is active + virtual int do_encoding() const throw() { return 0; } + + virtual std::codecvt_base::result do_in(std::mbstate_t& state, + const char* from, const char* from_end, const char*& from_next, + wchar_t* to, wchar_t* to_end, wchar_t*& to_next) const; + + virtual std::codecvt_base::result do_out(std::mbstate_t & state, + const wchar_t* from, const wchar_t* from_end, const wchar_t*& from_next, + char* to, char* to_end, char*& to_next) const; + + virtual std::codecvt_base::result do_unshift(std::mbstate_t&, + char* /*from*/, char* /*to*/, char* & /*next*/) const { return ok; } + + virtual int do_length(std::mbstate_t&, + const char* /*from*/, const char* /*from_end*/, std::size_t /*max*/) const { return 0; } + + virtual int do_max_length() const throw () { return 0; } + }; + +#endif // BOOST_FILESYSTEM3_WIN_FILE_CODECVT_HPP diff --git a/3party/fribidi/fribidi.pro b/3party/fribidi/fribidi.pro index 2ba36e9b37..f8a9a6f802 100644 --- a/3party/fribidi/fribidi.pro +++ b/3party/fribidi/fribidi.pro @@ -3,7 +3,7 @@ TEMPLATE = lib CONFIG += staticlib -INCLUDEPATH += ./lib +INCLUDEPATH += ./lib ./ ROOT_DIR = ../.. diff --git a/3party/fribidi/lib/common.h b/3party/fribidi/lib/common.h index 55a01ee81e..9ceb7f28dc 100644 --- a/3party/fribidi/lib/common.h +++ b/3party/fribidi/lib/common.h @@ -46,7 +46,7 @@ #endif /* !FRIBIDI_PRIVATESPACE */ #if (defined(WIN32)) || (defined(_WIN32_WCE)) -# define FRIBIDI_ENTRY __declspec(dllexport) +# define FRIBIDI_ENTRY //__declspec(dllexport) #endif /* WIN32 */ #if FRIBIDI_USE_GLIB+0 diff --git a/3party/fribidi/lib/fribidi-common.h b/3party/fribidi/lib/fribidi-common.h index b8f0d0763c..cccfc4b5e4 100644 --- a/3party/fribidi/lib/fribidi-common.h +++ b/3party/fribidi/lib/fribidi-common.h @@ -54,7 +54,7 @@ /* FRIBIDI_ENTRY is a macro used to declare library entry points. */ #ifndef FRIBIDI_ENTRY # if (defined(WIN32)) || (defined(_WIN32_WCE)) -# define FRIBIDI_ENTRY __declspec(dllimport) +# define FRIBIDI_ENTRY //__declspec(dllimport) # else /* !WIN32 */ # define FRIBIDI_ENTRY /* empty */ # endif /* !WIN32 */ diff --git a/3party/gflags/src/gflags/gflags.h b/3party/gflags/src/gflags/gflags.h index f742e418c3..1d9e964a52 100644 --- a/3party/gflags/src/gflags/gflags.h +++ b/3party/gflags/src/gflags/gflags.h @@ -283,7 +283,10 @@ class GFLAGS_DLL_DECL FlagSaver { FlagSaver(const FlagSaver&); // no copying! void operator=(const FlagSaver&); } -__attribute__ ((unused)); +#ifndef _MSC_VER +__attribute__ ((unused)) +#endif +; // -------------------------------------------------------------------- // Some deprecated or hopefully-soon-to-be-deprecated functions. diff --git a/3party/gmock/gmock.pro b/3party/gmock/gmock.pro index 1a5dd8a78b..4c48febd04 100644 --- a/3party/gmock/gmock.pro +++ b/3party/gmock/gmock.pro @@ -4,7 +4,7 @@ include($$ROOT_DIR/common.pri) TEMPLATE = lib CONFIG += staticlib warn_off -INCLUDEPATH += ./gtest/ ./gtest/include ./include +INCLUDEPATH += ./gtest/ ./gtest/include ./include ./ SOURCES += \ src/gmock-all.cc \ diff --git a/3party/jansson/src/jansson_config.h b/3party/jansson/src/jansson_config.h index ce5b240443..1f194957f6 100644 --- a/3party/jansson/src/jansson_config.h +++ b/3party/jansson/src/jansson_config.h @@ -24,7 +24,7 @@ #ifdef __cplusplus #define JSON_INLINE inline #else -#define JSON_INLINE inline +#define JSON_INLINE #endif /* If your compiler supports the `long long` type and the strtoll() diff --git a/3party/osrm/osrm.pro b/3party/osrm/osrm.pro index 192f9ec14a..100de097b4 100644 --- a/3party/osrm/osrm.pro +++ b/3party/osrm/osrm.pro @@ -4,7 +4,7 @@ CONFIG += staticlib ROOT_DIR = ../.. -QMAKE_CXXFLAGS *= -Wno-unused-function -Wno-unused-const-variable -Wno-ignored-qualifiers +!win32* : QMAKE_CXXFLAGS *= -Wno-unused-function -Wno-unused-const-variable -Wno-ignored-qualifiers include($$ROOT_DIR/common.pri) diff --git a/3party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc b/3party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc index f552e1f885..b3a71ce31d 100644 --- a/3party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +++ b/3party/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc @@ -36,6 +36,8 @@ #include #include +#include + namespace google { namespace protobuf { namespace io { diff --git a/anim/controller.cpp b/anim/controller.cpp index 2366a52c62..1ac5e21fc4 100644 --- a/anim/controller.cpp +++ b/anim/controller.cpp @@ -22,7 +22,7 @@ namespace anim void Controller::AddTask(TTaskPtr const & task) { - m_tasks.ProcessList([&](TTasks & taskList) + m_tasks.ProcessList([&] (TTasks & taskList) { taskList.push_back(task); task->SetController(this); @@ -57,7 +57,7 @@ namespace anim void Controller::PerformStep() { - m_tasks.ProcessList([this](TTasks & from) + m_tasks.ProcessList([this] (TTasks & from) { m_tasksList.clear(); swap(from, m_tasksList); @@ -93,9 +93,9 @@ namespace anim } m_hasVisualTasks = false; - m_tasks.ProcessList([&](TTasks & to) + m_tasks.ProcessList([&] (TTasks & to) { - for_each(resultList.begin(), resultList.end(), [&](TTaskPtr const & task) + for_each(resultList.begin(), resultList.end(), [&] (TTaskPtr const & task) { m_hasVisualTasks |= task->IsVisual(); to.push_back(task); diff --git a/anim/task.cpp b/anim/task.cpp index d4f213ae74..7511d2b4d2 100644 --- a/anim/task.cpp +++ b/anim/task.cpp @@ -37,7 +37,7 @@ namespace anim void Task::PerformCallbacks(EState state) { list const & cb = m_Callbacks[state]; - for_each(cb.begin(), cb.end(), [] (TCallback const & cb) { cb(); }); + for_each(cb.begin(), cb.end(), [] (TCallback const & el) { el(); }); } void Task::OnStart(double ts) diff --git a/base/commands_queue.cpp b/base/commands_queue.cpp index 8a784031a5..45c6d22307 100644 --- a/base/commands_queue.cpp +++ b/base/commands_queue.cpp @@ -242,7 +242,7 @@ namespace core /// to prevent the situation when Executor could start processing some command /// between "operation A" and "operation B" which could lead to underflow of m_activeCommands - m_commands.ProcessList(bind(&CommandsQueue::ClearImpl, this, _1)); + m_commands.ProcessList([this] (list > & l) { ClearImpl(l); }); } int CommandsQueue::ExecutorsCount() const diff --git a/base/condition_windows_native.cpp b/base/condition_windows_native.cpp index 710989bdc7..bee69f79a2 100644 --- a/base/condition_windows_native.cpp +++ b/base/condition_windows_native.cpp @@ -24,6 +24,7 @@ namespace threads virtual void Wait() = 0; virtual bool Wait(unsigned ms) = 0; virtual void Lock() = 0; + virtual bool TryLock() = 0; virtual void Unlock() = 0; }; @@ -276,6 +277,11 @@ namespace threads m_pImpl->Lock(); } + bool Condition::TryLock() + { + return m_pImpl->TryLock(); + } + void Condition::Unlock() { m_pImpl->Unlock(); diff --git a/base/internal/fast_mutex.hpp b/base/internal/fast_mutex.hpp index c9555fee2e..9a632dbb2c 100644 --- a/base/internal/fast_mutex.hpp +++ b/base/internal/fast_mutex.hpp @@ -175,7 +175,7 @@ # endif // _PTHREADS # ifdef _WIN32THREADS -# include +# include "../../std/windows.hpp" /** * Macro alias to `volatile' semantics. Here it is truly volatile since * it is in a multi-threaded (Win32 threads) environment. diff --git a/base/resource_pool.hpp b/base/resource_pool.hpp index 8570e292e2..301536871c 100644 --- a/base/resource_pool.hpp +++ b/base/resource_pool.hpp @@ -131,7 +131,7 @@ struct SeparateFreePoolTraits : TBase void UpdateState() { - m_freePool.ProcessList(bind(&SeparateFreePoolTraits::UpdateStateImpl, this, _1)); + m_freePool.ProcessList([this] (list & l) { UpdateStateImpl(l); }); } }; @@ -195,7 +195,7 @@ struct AllocateOnDemandMultiThreadedPoolTraits : TBase elem_t const Reserve() { elem_t res; - base_t::m_pool.ProcessList(bind(&self_t::AllocateAndReserve, this, _1, ref(res))); + base_t::m_pool.ProcessList([this, &res] (list & l) { AllocateAndReserve(l, res); }); return res; } @@ -241,7 +241,7 @@ struct AllocateOnDemandSingleThreadedPoolTraits : TBase elem_t res; /// allocate resources if needed if we're on the main thread. if (threads::GetCurrentThreadID() == base_t::m_MainThreadID) - base_t::m_pool.ProcessList(bind(&self_t::AllocateAndReserve, this, _1, ref(res))); + base_t::m_pool.ProcessList([this, &res] (list & l) { AllocateAndReserve(l, res); }); else res = base_t::Reserve(); return res; @@ -259,7 +259,7 @@ struct AllocateOnDemandSingleThreadedPoolTraits : TBase void UpdateState() { base_t::UpdateState(); - base_t::m_pool.ProcessList(bind(&self_t::AllocateIfNeeded, this, _1)); + base_t::m_pool.ProcessList([this] (list & l) { AllocateIfNeeded(l); }); } }; diff --git a/base/shared_buffer_manager.cpp b/base/shared_buffer_manager.cpp index 8c177ae615..2d20148560 100644 --- a/base/shared_buffer_manager.cpp +++ b/base/shared_buffer_manager.cpp @@ -1,4 +1,3 @@ -#include "../base/SRC_FIRST.hpp" #include "shared_buffer_manager.hpp" diff --git a/base/thread.cpp b/base/thread.cpp index 6bedfb0b36..f226990d6e 100644 --- a/base/thread.cpp +++ b/base/thread.cpp @@ -1,9 +1,7 @@ #include "thread.hpp" #include "assert.hpp" -#if defined(OMIM_OS_WINDOWS_NATIVE) - #include "../std/windows.hpp" -#else +#if !defined(OMIM_OS_WINDOWS_NATIVE) #include #if defined (OMIM_OS_ANDROID) /// External implementations are in android/jni code diff --git a/base/thread_pool.cpp b/base/thread_pool.cpp index 9708b4a37b..06271ccc54 100644 --- a/base/thread_pool.cpp +++ b/base/thread_pool.cpp @@ -95,7 +95,7 @@ namespace threads } m_threads.clear(); - m_tasks.ProcessList(bind(&ThreadPool::Impl::FinishTasksOnStop, this, _1)); + m_tasks.ProcessList([this] (list & tasks) { FinishTasksOnStop(tasks); }); m_tasks.Clear(); } diff --git a/base/timer.cpp b/base/timer.cpp index 68fb41ccee..8ff524bca3 100644 --- a/base/timer.cpp +++ b/base/timer.cpp @@ -33,7 +33,7 @@ double Timer::LocalTime() #else timeval tv; - gettimeofday(&tv, 0); + ::gettimeofday(&tv, 0); return tv.tv_sec + tv.tv_usec / 1000000.0; #endif } diff --git a/coding/coding.pro b/coding/coding.pro index 3d05789a76..fa85a59d49 100644 --- a/coding/coding.pro +++ b/coding/coding.pro @@ -7,10 +7,7 @@ ROOT_DIR = .. include($$ROOT_DIR/common.pri) -INCLUDEPATH *= ../3party/tomcrypt/src/headers ../3party/zlib - -# use expat from the system on linux -!linux*: INCLUDEPATH *= ../3party/expat/lib +INCLUDEPATH *= $$ROOT_DIR/3party/tomcrypt/src/headers $$ROOT_DIR/3party/zlib $$ROOT_DIR/3party/expat/lib SOURCES += \ internal/file_data.cpp \ diff --git a/coding/coding_tests/file_container_test.cpp b/coding/coding_tests/file_container_test.cpp index 5f8d77e830..05f788d7c3 100644 --- a/coding/coding_tests/file_container_test.cpp +++ b/coding/coding_tests/file_container_test.cpp @@ -279,7 +279,12 @@ UNIT_TEST(FilesMappingContainer_PageSize) { string const fName = "file_container.tmp"; - size_t const pageSize = sysconf(_SC_PAGE_SIZE); + size_t const pageSize = +#ifndef OMIM_OS_WINDOWS + sysconf(_SC_PAGE_SIZE); +#else + 4096; +#endif LOG(LINFO, ("Page size:", pageSize)); char const * key[] = { "3", "2", "1" }; diff --git a/coding/file_container.cpp b/coding/file_container.cpp index 2e51a41dd2..244e08c511 100644 --- a/coding/file_container.cpp +++ b/coding/file_container.cpp @@ -14,6 +14,14 @@ #else #include #endif +#else + // @TODO what to do with mmap on Windows? + #define MAP_FAILED (void*)0 + #define mmap(a,b,c,d,e,f) MAP_FAILED + #define sysconf(a) {} + #define open(a,b) {} + #define munmap(a,b) MAP_FAILED + #define close(a) {} #endif diff --git a/coding/parse_xml.hpp b/coding/parse_xml.hpp index 5d9f84deb8..d5bb6d129b 100644 --- a/coding/parse_xml.hpp +++ b/coding/parse_xml.hpp @@ -16,7 +16,7 @@ uint64_t ParseXMLSequence(SequenceT & source, XMLDispatcherT & dispatcher, bool int const BUFFER_SIZE = 16 * 1024; uint64_t res = 0; - int readed; + uint64_t readed; do { char * buffer = static_cast(parser.GetBuffer(BUFFER_SIZE)); @@ -48,7 +48,7 @@ public: SequenceAdapter(SourceT & source) : m_source(source) {} uint64_t Read(void * p, uint64_t size) { - uint64_t const correctSize = min(size, m_source.Size()); + size_t const correctSize = min(size, m_source.Size()); m_source.Read(p, correctSize); return correctSize; } diff --git a/common.pri b/common.pri index f5366097da..79a851a87a 100644 --- a/common.pri +++ b/common.pri @@ -18,8 +18,10 @@ CONFIG -= depend_includepath CONFIG *= c++11 -QMAKE_CFLAGS *= -Wno-deprecated-register -QMAKE_CXXFLAGS *= -Wno-deprecated-register +!win32* { + QMAKE_CFLAGS *= -Wno-deprecated-register + QMAKE_CXXFLAGS *= -Wno-deprecated-register +} # Automatically enable release config for production CONFIG(production) { @@ -64,10 +66,7 @@ unix|win32-g++|tizen* { # Add libraries' dependencies. for(project, DEPENDENCIES) { - equals(project,expat):linux* { - } else { - PRE_TARGETDEPS += $$BINARIES_PATH/$$LIB_PREFIX$$project$$LIB_EXT - } + PRE_TARGETDEPS += $$BINARIES_PATH/$$LIB_PREFIX$$project$$LIB_EXT LIBS += -l$$project } @@ -84,9 +83,9 @@ win32 { win32-msvc* { QMAKE_CLEAN += *.user - DEFINES += _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS NOMINMAX NO_MIN_MAX - QMAKE_CXXFLAGS += /Fd$${DESTDIR}/$${TARGET}.pdb /Zi /fp:fast - QMAKE_CFLAGS += /Fd$${DESTDIR}/$${TARGET}.pdb /Zi /fp:fast + DEFINES += _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS _CRT_NONSTDC_NO_WARNINGS NOMINMAX NO_MIN_MAX _USE_MATH_DEFINES BOOST_ALL_NO_LIB + QMAKE_CXXFLAGS += /Zi /fp:fast + QMAKE_CFLAGS += /Zi /fp:fast QMAKE_CXXFLAGS_RELEASE -= /O2 # don't set -GL - bug in msvc2008 @@ -95,7 +94,7 @@ win32-msvc* { QMAKE_LFLAGS_RELEASE += /MACHINE:X86 QMAKE_LFLAGS *= /OPT:REF - QMAKE_LFLAGS_RELEASE *= /OPT:ICF + QMAKE_LFLAGS_RELEASE *= /OPT:REF,ICF QMAKE_LFLAGS_DEBUG *= /OPT:NOICF CONFIG(release, debug|release) { @@ -105,8 +104,10 @@ win32-msvc* { win32-msvc201* { # disable tr1 and c++0x features to avoid build errors - DEFINES += _HAS_CPP0X=0 - DEFINES += BOOST_NO_CXX11_HDR_ARRAY BOOST_NO_CXX11_HDR_TYPEINDEX BOOST_NO_CXX11_SMART_PTR +# DEFINES += _HAS_CPP0X=0 +# DEFINES += BOOST_NO_CXX11_HDR_ARRAY BOOST_NO_CXX11_HDR_TYPEINDEX BOOST_NO_CXX11_SMART_PTR + QMAKE_CFLAGS *= /wd4100 + QMAKE_CXXFLAGS *= /wd4100 QMAKE_CFLAGS_RELEASE += /GL QMAKE_CXXFLAGS_RELEASE += /GL QMAKE_LFLAGS_RELEASE += /LTCG diff --git a/drape/drape.pro b/drape/drape.pro index 90b932aab0..5b4e73ba0e 100644 --- a/drape/drape.pro +++ b/drape/drape.pro @@ -17,6 +17,8 @@ include($$ROOT_DIR/common.pri) DRAPE_DIR = . include($$DRAPE_DIR/drape_common.pri) +INCLUDEPATH *= $$ROOT_DIR/3party/expat/lib + SOURCES += glfunctions.cpp OTHER_FILES += \ diff --git a/drape/drape_tests/compile_shaders_test.cpp b/drape/drape_tests/compile_shaders_test.cpp index c7de8cd9e4..9b6dafbec9 100644 --- a/drape/drape_tests/compile_shaders_test.cpp +++ b/drape/drape_tests/compile_shaders_test.cpp @@ -131,18 +131,18 @@ UNIT_TEST(CompileShaders_Test) ShaderEnumGuard guard; QString compilerPath = QString::fromStdString(glslCompilerPath); QString shaderType = "-v"; - auto argsPrepareFn = [&shaderType](QStringList & args, QString const & fileName) + auto argsPrepareFn = [&shaderType] (QStringList & args, QString const & fileName) { args << fileName << fileName + ".bin" << shaderType; }; - auto successComparator = [](QString const & output) { return output.indexOf("Success") != -1; }; + auto successComparator = [] (QString const & output) { return output.indexOf("Success") != -1; }; - ForEachShader(gpu::VertexEnum, compilerPath, [](QProcess const &){}, + ForEachShader(gpu::VertexEnum, compilerPath, [] (QProcess const &) {}, argsPrepareFn, successComparator, ss); shaderType = "-f"; - ForEachShader(gpu::FragmentEnum, compilerPath,[](QProcess const &){}, + ForEachShader(gpu::FragmentEnum, compilerPath,[] (QProcess const &) {}, argsPrepareFn, successComparator, ss); TEST_EQUAL(errorLog.isEmpty(), true, (errorLog)); @@ -163,9 +163,9 @@ void TestMaliShaders(QString const & driver, QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); env.insert("MALICM_LOCATION", QString::fromStdString(platform.ResourcesDir() + "shaders_compiler/" MALI_DIR)); - auto procPrepare = [&env](QProcess & p) { p.setProcessEnvironment(env); }; + auto procPrepare = [&env] (QProcess & p) { p.setProcessEnvironment(env); }; QString shaderType = "-v"; - auto argForming = [&](QStringList & args, QString const & fileName) + auto argForming = [&] (QStringList & args, QString const & fileName) { args << shaderType << "-V" @@ -178,7 +178,7 @@ void TestMaliShaders(QString const & driver, << fileName; }; - auto succesComparator = [](QString const & output) + auto succesComparator = [] (QString const & output) { return output.indexOf("Compilation succeeded.") != -1; }; diff --git a/drape/drape_tests/drape_tests.pro b/drape/drape_tests/drape_tests.pro index cc8d95a04c..decb8d076e 100644 --- a/drape/drape_tests/drape_tests.pro +++ b/drape/drape_tests/drape_tests.pro @@ -20,11 +20,10 @@ QT *= core DRAPE_DIR = .. include($$DRAPE_DIR/drape_common.pri) -INCLUDEPATH += $$ROOT_DIR/3party/gmock/include $$ROOT_DIR/3party/gmock/gtest/include +INCLUDEPATH *= $$ROOT_DIR/3party/gmock/include $$ROOT_DIR/3party/gmock/gtest/include $$ROOT_DIR/3party/expat/lib -macx-* { - LIBS *= "-framework CoreLocation" "-framework Foundation" -} +win32* : LIBS *= -lShell32 +macx-* : LIBS *= "-framework CoreLocation" "-framework Foundation" SOURCES += \ glfunctions.cpp \ diff --git a/drape/glIncludes.hpp b/drape/glIncludes.hpp index 226d916bba..421bc8bf4f 100644 --- a/drape/glIncludes.hpp +++ b/drape/glIncludes.hpp @@ -8,6 +8,11 @@ #elif defined(OMIM_OS_MAC) #include #include +#elif defined(OMIM_OS_WINDOWS) + #include "../std/windows.hpp" + #define GL_GLEXT_PROTOTYPES + #include + #include "../3party/GL/glext.h" #else #define GL_GLEXT_PROTOTYPES #include diff --git a/drape/glfunctions.cpp b/drape/glfunctions.cpp index 4134430756..9d8a2729c2 100644 --- a/drape/glfunctions.cpp +++ b/drape/glfunctions.cpp @@ -6,6 +6,9 @@ #include "../std/cstring.hpp" +#ifndef OMIM_OS_WINDOWS +#define APIENTRY +#endif namespace { @@ -14,58 +17,58 @@ namespace return (v == true) ? GL_TRUE : GL_FALSE; } - void (*glClearColorFn)(GLfloat r, GLfloat g, GLfloat b, GLfloat a) = NULL; - void (*glClearFn)(GLbitfield mask) = NULL; - void (*glViewportFn)(GLint x, GLint y, GLsizei w, GLsizei h) = NULL; - void (*glFlushFn)() = NULL; + void (APIENTRY *glClearColorFn)(GLfloat r, GLfloat g, GLfloat b, GLfloat a) = NULL; + void (APIENTRY *glClearFn)(GLbitfield mask) = NULL; + void (APIENTRY *glViewportFn)(GLint x, GLint y, GLsizei w, GLsizei h) = NULL; + void (APIENTRY *glFlushFn)() = NULL; - void (*glBindFramebufferFn)(GLenum target, GLuint id) = NULL; + void (APIENTRY *glBindFramebufferFn)(GLenum target, GLuint id) = NULL; /// VAO - void (*glGenVertexArraysFn)(GLsizei n, GLuint * ids) = NULL; - void (*glBindVertexArrayFn)(GLuint id) = NULL; - void (*glDeleteVertexArrayFn)(GLsizei n, GLuint const * ids) = NULL; + void (APIENTRY *glGenVertexArraysFn)(GLsizei n, GLuint * ids) = NULL; + void (APIENTRY *glBindVertexArrayFn)(GLuint id) = NULL; + void (APIENTRY *glDeleteVertexArrayFn)(GLsizei n, GLuint const * ids) = NULL; /// VBO - void (*glGenBuffersFn)(GLsizei n, GLuint * buffers) = NULL; - void (*glBindBufferFn)(GLenum target, GLuint buffer) = NULL; - void (*glDeleteBuffersFn)(GLsizei n, GLuint const * buffers) = NULL; - void (*glBufferDataFn)(GLenum target, GLsizeiptr size, GLvoid const * data, GLenum usage) = NULL; - void (*glBufferSubDataFn)(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid const * data) = NULL; - void * (*glMapBufferFn)(GLenum target, GLenum access) = NULL; - GLboolean (*glUnmapBufferFn)(GLenum target) = NULL; + void (APIENTRY *glGenBuffersFn)(GLsizei n, GLuint * buffers) = NULL; + void (APIENTRY *glBindBufferFn)(GLenum target, GLuint buffer) = NULL; + void (APIENTRY *glDeleteBuffersFn)(GLsizei n, GLuint const * buffers) = NULL; + void (APIENTRY *glBufferDataFn)(GLenum target, GLsizeiptr size, GLvoid const * data, GLenum usage) = NULL; + void (APIENTRY *glBufferSubDataFn)(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid const * data) = NULL; + void * (APIENTRY *glMapBufferFn)(GLenum target, GLenum access) = NULL; + GLboolean (APIENTRY *glUnmapBufferFn)(GLenum target) = NULL; /// Shaders - GLuint (*glCreateShaderFn)(GLenum type) = NULL; - void (*glShaderSourceFn)(GLuint shaderID, GLsizei count, GLchar const ** string, GLint const * length) = NULL; - void (*glCompileShaderFn)(GLuint shaderID) = NULL; - void (*glDeleteShaderFn)(GLuint shaderID) = NULL; - void (*glGetShaderivFn)(GLuint shaderID, GLenum name, GLint * p) = NULL; - void (*glGetShaderInfoLogFn)(GLuint shaderID, GLsizei maxLength, GLsizei * length, GLchar * infoLog) = NULL; + GLuint (APIENTRY *glCreateShaderFn)(GLenum type) = NULL; + void (APIENTRY *glShaderSourceFn)(GLuint shaderID, GLsizei count, GLchar const ** string, GLint const * length) = NULL; + void (APIENTRY *glCompileShaderFn)(GLuint shaderID) = NULL; + void (APIENTRY *glDeleteShaderFn)(GLuint shaderID) = NULL; + void (APIENTRY *glGetShaderivFn)(GLuint shaderID, GLenum name, GLint * p) = NULL; + void (APIENTRY *glGetShaderInfoLogFn)(GLuint shaderID, GLsizei maxLength, GLsizei * length, GLchar * infoLog) = NULL; - GLuint (*glCreateProgramFn)() = NULL; - void (*glAttachShaderFn)(GLuint programID, GLuint shaderID) = NULL; - void (*glDetachShaderFn)(GLuint programID, GLuint shaderID) = NULL; - void (*glLinkProgramFn)(GLuint programID) = NULL; - void (*glDeleteProgramFn)(GLuint programID) = NULL; - void (*glGetProgramivFn)(GLuint programID, GLenum name, GLint * p) = NULL; - void (*glGetProgramInfoLogFn)(GLuint programID, GLsizei maxLength, GLsizei * length, GLchar * infoLog) = NULL; + GLuint (APIENTRY *glCreateProgramFn)() = NULL; + void (APIENTRY *glAttachShaderFn)(GLuint programID, GLuint shaderID) = NULL; + void (APIENTRY *glDetachShaderFn)(GLuint programID, GLuint shaderID) = NULL; + void (APIENTRY *glLinkProgramFn)(GLuint programID) = NULL; + void (APIENTRY *glDeleteProgramFn)(GLuint programID) = NULL; + void (APIENTRY *glGetProgramivFn)(GLuint programID, GLenum name, GLint * p) = NULL; + void (APIENTRY *glGetProgramInfoLogFn)(GLuint programID, GLsizei maxLength, GLsizei * length, GLchar * infoLog) = NULL; - void (*glUseProgramFn)(GLuint programID) = NULL; - GLint (*glGetAttribLocationFn)(GLuint program, GLchar const * name) = NULL; - void (*glBindAttribLocationFn)(GLuint program, GLuint index, GLchar const * name) = NULL; + void (APIENTRY *glUseProgramFn)(GLuint programID) = NULL; + GLint (APIENTRY *glGetAttribLocationFn)(GLuint program, GLchar const * name) = NULL; + void (APIENTRY *glBindAttribLocationFn)(GLuint program, GLuint index, GLchar const * name) = NULL; - void (*glEnableVertexAttributeFn)(GLuint location) = NULL; - void (*glVertexAttributePointerFn)(GLuint index, + void (APIENTRY *glEnableVertexAttributeFn)(GLuint location) = NULL; + void (APIENTRY *glVertexAttributePointerFn)(GLuint index, GLint count, GLenum type, GLboolean normalize, GLsizei stride, GLvoid const * p) = NULL; - GLint (*glGetUniformLocationFn)(GLuint programID, GLchar const * name) = NULL; + GLint (APIENTRY *glGetUniformLocationFn)(GLuint programID, GLchar const * name) = NULL; - void (*glGetActiveUniformFn)(GLuint programID, + void (APIENTRY *glGetActiveUniformFn)(GLuint programID, GLuint uniformIndex, GLsizei bufSize, GLsizei * length, @@ -73,19 +76,19 @@ namespace GLenum * type, GLchar * name) = NULL; - void (*glUniform1iFn)(GLint location, GLint value) = NULL; - void (*glUniform2iFn)(GLint location, GLint v1, GLint v2) = NULL; - void (*glUniform3iFn)(GLint location, GLint v1, GLint v2, GLint v3) = NULL; - void (*glUniform4iFn)(GLint location, GLint v1, GLint v2, GLint v3, GLint v4) = NULL; - void (*glUniform1ivFn)(GLint location, GLsizei count, GLint const * value) = NULL; + void (APIENTRY *glUniform1iFn)(GLint location, GLint value) = NULL; + void (APIENTRY *glUniform2iFn)(GLint location, GLint v1, GLint v2) = NULL; + void (APIENTRY *glUniform3iFn)(GLint location, GLint v1, GLint v2, GLint v3) = NULL; + void (APIENTRY *glUniform4iFn)(GLint location, GLint v1, GLint v2, GLint v3, GLint v4) = NULL; + void (APIENTRY *glUniform1ivFn)(GLint location, GLsizei count, GLint const * value) = NULL; - void (*glUniform1fFn)(GLint location, GLfloat value) = NULL; - void (*glUniform2fFn)(GLint location, GLfloat v1, GLfloat v2) = NULL; - void (*glUniform3fFn)(GLint location, GLfloat v1, GLfloat v2, GLfloat v3) = NULL; - void (*glUniform4fFn)(GLint location, GLfloat v1, GLfloat v2, GLfloat v3, GLfloat v4) = NULL; - void (*glUniform1fvFn)(GLint location, GLsizei count, GLfloat const * value) = NULL; + void (APIENTRY *glUniform1fFn)(GLint location, GLfloat value) = NULL; + void (APIENTRY *glUniform2fFn)(GLint location, GLfloat v1, GLfloat v2) = NULL; + void (APIENTRY *glUniform3fFn)(GLint location, GLfloat v1, GLfloat v2, GLfloat v3) = NULL; + void (APIENTRY *glUniform4fFn)(GLint location, GLfloat v1, GLfloat v2, GLfloat v3, GLfloat v4) = NULL; + void (APIENTRY *glUniform1fvFn)(GLint location, GLsizei count, GLfloat const * value) = NULL; - void (*glUniformMatrix4fvFn)(GLint location, GLsizei count, GLboolean transpose, GLfloat const * value) = NULL; + void (APIENTRY *glUniformMatrix4fvFn)(GLint location, GLsizei count, GLboolean transpose, GLfloat const * value) = NULL; int const GLCompileStatus = GL_COMPILE_STATUS; int const GLLinkStatus = GL_LINK_STATUS; @@ -126,7 +129,7 @@ void GLFunctions::Init() /// Shaders glCreateShaderFn = &::glCreateShader; - typedef void (*glShaderSource_Type)(GLuint shaderID, GLsizei count, GLchar const ** string, GLint const * length); + typedef void (APIENTRY *glShaderSource_Type)(GLuint shaderID, GLsizei count, GLchar const ** string, GLint const * length); glShaderSourceFn = reinterpret_cast(&::glShaderSource); glCompileShaderFn = &::glCompileShader; glDeleteShaderFn = &::glDeleteShader; diff --git a/drape/symbols_texture.cpp b/drape/symbols_texture.cpp index e118efc77c..6ca2f73627 100644 --- a/drape/symbols_texture.cpp +++ b/drape/symbols_texture.cpp @@ -138,7 +138,7 @@ void SymbolsTexture::Load(string const & skinPathName) { ReaderPtr reader = GetPlatform().GetReader(skinPathName + ".png"); - uint64_t size = reader.Size(); + size_t const size = reader.Size(); rawData.resize(size); reader.Read(0, &rawData[0], size); } diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 9129b66d73..d16a72cbef 100644 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -25,15 +25,15 @@ const double VSyncInterval = 0.014; //const double InitAvarageTimePerMessage = 0.001; #endif -void OrthoMatrix(float * m, float left, float right, float bottom, float top, float near, float far) +void OrthoMatrix(float * m, float left, float right, float bottom, float top, float nearClip, float farClip) { memset(m, 0, 16 * sizeof(float)); m[0] = 2.0f / (right - left); m[3] = - (right + left) / (right - left); m[5] = 2.0f / (top - bottom); m[7] = - (top + bottom) / (top - bottom); - m[10] = -2.0f / (far - near); - m[11] = - (far + near) / (far - near); + m[10] = -2.0f / (farClip - nearClip); + m[11] = - (farClip + nearClip) / (farClip - nearClip); m[15] = 1.0; } diff --git a/drape_frontend/read_manager.cpp b/drape_frontend/read_manager.cpp index fdee489f19..7943ed6135 100644 --- a/drape_frontend/read_manager.cpp +++ b/drape_frontend/read_manager.cpp @@ -62,12 +62,18 @@ void ReadManager::UpdateCoverage(ScreenBase const & screen, set const & { // Find rects that go out from viewport buffer_vector outdatedTiles; +#ifdef _MSC_VER + vs_bug:: +#endif set_difference(m_tileInfos.begin(), m_tileInfos.end(), tiles.begin(), tiles.end(), back_inserter(outdatedTiles), LessCoverageCell()); // Find rects that go in into viewport buffer_vector inputRects; +#ifdef _MSC_VER + vs_bug:: +#endif set_difference(tiles.begin(), tiles.end(), m_tileInfos.begin(), m_tileInfos.end(), back_inserter(inputRects), LessCoverageCell()); diff --git a/drape_head/drape_head.pro b/drape_head/drape_head.pro index 08000eea03..0555a1434c 100644 --- a/drape_head/drape_head.pro +++ b/drape_head/drape_head.pro @@ -9,12 +9,12 @@ INCLUDEPATH += $$ROOT_DIR/3party/jansson/src TARGET = DrapeHead TEMPLATE = app CONFIG += warn_on -QT *= core gui widgets +QT *= core gui widgets opengl #DEFINES += USE_TESTING_ENGINE win32* { LIBS += -lopengl32 -lws2_32 -lshell32 -liphlpapi - RC_FILE = res/windows.rc +# RC_FILE = res/windows.rc win32-msvc*: LIBS += -lwlanapi win32-g++: LIBS += -lpthread } diff --git a/drape_head/testing_engine.cpp b/drape_head/testing_engine.cpp index 54a69075ac..79a3cb7f17 100644 --- a/drape_head/testing_engine.cpp +++ b/drape_head/testing_engine.cpp @@ -698,21 +698,20 @@ void TestingEngine::ModelViewInit() void TestingEngine::ProjectionInit() { - float left = m_viewport.GetX0(); - float right = left + m_viewport.GetWidth(); - float bottom = m_viewport.GetY0(); - float top = bottom + m_viewport.GetHeight(); - float near = -20000.0f; - float far = 20000.0f; + float const left = m_viewport.GetX0(); + float const right = left + m_viewport.GetWidth(); + float const bottom = m_viewport.GetY0(); + float const top = bottom + m_viewport.GetHeight(); + float const nearClip = -20000.0f; + float const farClip = 20000.0f; - float m[4 * 4]; - memset(m, 0, sizeof(m)); + float m[4 * 4] = {0.}; m[0] = 2.0f / (right - left); m[3] = - (right + left) / (right - left); m[5] = 2.0f / (bottom - top); m[7] = - (bottom + top) / (bottom - top); - m[10] = -2.0f / (far - near); - m[11] = - (far + near) / (far - near); + m[10] = -2.0f / (farClip - nearClip); + m[11] = - (farClip + nearClip) / (farClip - nearClip); m[15] = 1.0; m_generalUniforms.SetMatrix4x4Value("projection", m); diff --git a/generator/borders_loader.cpp b/generator/borders_loader.cpp index d2e4ad50c6..eb9a86f31c 100644 --- a/generator/borders_loader.cpp +++ b/generator/borders_loader.cpp @@ -176,18 +176,18 @@ void GeneratePackedBorders(string const & baseDir) void ExportOSMPolylines(string const & outDir, CountriesContainerT const & countries) { - countries.ForEach( [&](CountryPolygons const & cp) + countries.ForEach( [&] (CountryPolygons const & cp) { // .poly file format described here: http://wiki.openstreetmap.org/wiki/Osmosis/Polygon_Filter_File_Format ostringstream stream; stream << cp.m_name << endl; size_t regionNumber = 0; - cp.m_regions.ForEach( [&](Region const & r) + cp.m_regions.ForEach( [&] (Region const & r) { stream << ++regionNumber << endl; - r.ForEachPoint( [&](m2::PointD const & pt) + r.ForEachPoint( [&] (m2::PointD const & pt) { stream << '\t' << std::scientific << MercatorBounds::XToLon(pt.x) << '\t' << MercatorBounds::YToLat(pt.y) << endl; } ); diff --git a/generator/generator.pro b/generator/generator.pro index efafd1da35..79e1a12343 100644 --- a/generator/generator.pro +++ b/generator/generator.pro @@ -8,7 +8,7 @@ ROOT_DIR = .. include($$ROOT_DIR/common.pri) -INCLUDEPATH *= $$ROOT_DIR/3party/gflags/src \ +INCLUDEPATH *= $$ROOT_DIR/3party/gflags/src $$ROOT_DIR/3party/expat/lib \ $$ROOT_DIR/3party/osrm/osrm-backend/Include QT *= core diff --git a/generator/generator_tests/generator_tests.pro b/generator/generator_tests/generator_tests.pro index 57e9e07601..bc3f91e40d 100644 --- a/generator/generator_tests/generator_tests.pro +++ b/generator/generator_tests/generator_tests.pro @@ -16,6 +16,8 @@ win32 { } macx-*: LIBS *= "-framework Foundation" +INCLUDEPATH *= $$ROOT_DIR/3party/expat/lib + HEADERS += \ SOURCES += \ diff --git a/generator/osm_element.hpp b/generator/osm_element.hpp index 6a8e9df743..e10b1082ae 100644 --- a/generator/osm_element.hpp +++ b/generator/osm_element.hpp @@ -269,7 +269,7 @@ class SecondPassParser : public BaseOSMParser ft.AddPoint(pts[i]); ft.AddOsmId(osm::Id::Relation(m_relID)); - m_pMain->EmitArea(ft, m_params, [this](FeatureBuilderT & ft) + m_pMain->EmitArea(ft, m_params, [this] (FeatureBuilderT & ft) { ft.SetAreaAddHoles(m_holes); }); diff --git a/geometry/region2d/binary_operators.cpp b/geometry/region2d/binary_operators.cpp index 24a512f14e..f743a1d4cc 100644 --- a/geometry/region2d/binary_operators.cpp +++ b/geometry/region2d/binary_operators.cpp @@ -1,7 +1,5 @@ -#include "../../base/SRC_FIRST.hpp" - -#include "binary_operators.hpp" #include "boost_concept.hpp" +#include "binary_operators.hpp" namespace m2 diff --git a/graphics/graphics.pro b/graphics/graphics.pro index 492a68faf0..dd1030c64b 100644 --- a/graphics/graphics.pro +++ b/graphics/graphics.pro @@ -7,10 +7,7 @@ DEFINES += GRAPHICS_LIBRARY ROOT_DIR = .. -INCLUDEPATH += $$ROOT_DIR/3party/freetype/include $$ROOT_DIR/3party/agg - -# use expat from the system on linux -!linux*: INCLUDEPATH *= ../3party/expat/lib +INCLUDEPATH += $$ROOT_DIR/3party/freetype/include $$ROOT_DIR/3party/agg $$ROOT_DIR/3party/expat/lib include($$ROOT_DIR/common.pri) diff --git a/graphics/opengl/gl_procedures.inl b/graphics/opengl/gl_procedures.inl index 657cc0395d..8f13fba3c3 100644 --- a/graphics/opengl/gl_procedures.inl +++ b/graphics/opengl/gl_procedures.inl @@ -2,7 +2,6 @@ // buffer objects extensions -DEFINE_GL_RPOC("glFlush", glFlushFn); DEFINE_GL_PROC("glActiveTexture", glActiveTextureFn) DEFINE_GL_PROC("glGetAttribLocation", glGetAttribLocationFn) DEFINE_GL_PROC("glGetActiveAttrib", glGetActiveAttribFn) diff --git a/graphics/opengl/opengl_win32.cpp b/graphics/opengl/opengl_win32.cpp index 646cd184f0..6cee36dab4 100644 --- a/graphics/opengl/opengl_win32.cpp +++ b/graphics/opengl/opengl_win32.cpp @@ -58,6 +58,9 @@ namespace graphics #include "gl_procedures.inl" #undef DEFINE_GL_PROC + // glFlush is a globally defined function + glFlushFn = &glFlush; + graphics::gl::g_isBufferObjectsSupported = glBindBufferFn && glGenBuffersFn && glBufferDataFn diff --git a/graphics/packets_queue.hpp b/graphics/packets_queue.hpp index cd42e2c56b..572e68a959 100644 --- a/graphics/packets_queue.hpp +++ b/graphics/packets_queue.hpp @@ -121,13 +121,13 @@ namespace graphics void cancelCommands(); template - void processFn(Fn fn, bool performOnCancel = false) + void processFn(Fn const & fn, bool performOnCancel = false) { processPacket(Packet(make_shared>(fn), Packet::ECommand)); } template - void processList(Fn fn) + void processList(Fn const & fn) { m_packets.ProcessList(fn); } diff --git a/indexer/index.hpp b/indexer/index.hpp index 16416e198b..45054ccfce 100644 --- a/indexer/index.hpp +++ b/indexer/index.hpp @@ -105,7 +105,7 @@ private: feature::DataHeader const & header = pValue->GetHeader(); // Prepare needed covering. - int const lastScale = header.GetLastScale(); + uint32_t const lastScale = header.GetLastScale(); // In case of WorldCoasts we should pass correct scale in ForEachInIntervalAndScale. if (scale > lastScale) scale = lastScale; diff --git a/map/active_maps_layout.cpp b/map/active_maps_layout.cpp index 2d86414837..ef25270a4e 100644 --- a/map/active_maps_layout.cpp +++ b/map/active_maps_layout.cpp @@ -55,7 +55,7 @@ void ActiveMapsLayout::Init(vector const & maps) } } - auto comparatorFn = [&storage](Item const & lhs, Item const & rhs) + auto comparatorFn = [&storage] (Item const & lhs, Item const & rhs) { if (lhs.m_status != rhs.m_status) return lhs.m_status > rhs.m_status; @@ -66,7 +66,7 @@ void ActiveMapsLayout::Init(vector const & maps) }; sort(m_items.begin(), m_items.end(), comparatorFn); - auto uniqPredicate = [](Item const & item1, Item const & item2) + auto uniqPredicate = [] (Item const & item1, Item const & item2) { return item1.m_index == item2.m_index; }; @@ -327,7 +327,7 @@ string const ActiveMapsLayout::GetFormatedCountryName(TIndex const & index) bool ActiveMapsLayout::IsDownloadingActive() const { - auto iter = find_if(m_items.begin(), m_items.end(), [](Item const & item) + auto iter = find_if(m_items.begin(), m_items.end(), [] (Item const & item) { return item.m_status == TStatus::EDownloading || item.m_status == TStatus::EInQueue; }); @@ -486,7 +486,7 @@ int ActiveMapsLayout::GetStartIndexInGroup(TGroup const & group) const ActiveMapsLayout::Item * ActiveMapsLayout::FindItem(TIndex const & index) { - vector::iterator iter = find_if(m_items.begin(), m_items.end(), [&index](Item const & item) + vector::iterator iter = find_if(m_items.begin(), m_items.end(), [&index] (Item const & item) { return item.m_index == index; }); @@ -499,7 +499,7 @@ ActiveMapsLayout::Item * ActiveMapsLayout::FindItem(TIndex const & index) ActiveMapsLayout::Item const * ActiveMapsLayout::FindItem(TIndex const & index) const { - vector::const_iterator iter = find_if(m_items.begin(), m_items.end(), [&index](Item const & item) + vector::const_iterator iter = find_if(m_items.begin(), m_items.end(), [&index] (Item const & item) { return item.m_index == index; }); @@ -569,12 +569,12 @@ int ActiveMapsLayout::InsertInGroup(TGroup const & group, Item const & item) } Storage & st = m_framework.Storage(); - sort(startSort, endSort, [&](Item const & lhs, Item const & rhs) + sort(startSort, endSort, [&] (Item const & lhs, Item const & rhs) { return st.CountryName(lhs.m_index) < st.CountryName(rhs.m_index); }); - TItemIter newPosIter = find_if(startSort, endSort, [&item](Item const & it) + TItemIter newPosIter = find_if(startSort, endSort, [&item] (Item const & it) { return it.m_index == item.m_index; }); diff --git a/map/country_status_display.cpp b/map/country_status_display.cpp index 03d58e9f4b..8072728bb9 100644 --- a/map/country_status_display.cpp +++ b/map/country_status_display.cpp @@ -31,7 +31,7 @@ CountryStatusDisplay::CountryStatusDisplay(Params const & p) bp.m_minHeight = 40; bp.m_position = graphics::EPosCenter; - auto createButtonFn = [this](gui::Button::Params const & params) + auto createButtonFn = [this] (gui::Button::Params const & params) { gui::Button * result = new gui::Button(params); result->setIsVisible(false); @@ -158,7 +158,7 @@ void CountryStatusDisplay::purge() void CountryStatusDisplay::cache() { - auto cacheFn = [](gui::Element * e) + auto cacheFn = [] (gui::Element * e) { if (e->isVisible()) e->cache(); @@ -389,7 +389,7 @@ void CountryStatusDisplay::ComposeElementsForState() { ASSERT(isVisible(), ()); int visibleCount = 0; - auto visibleCheckFn = [&visibleCount](gui::Element const * e) + auto visibleCheckFn = [&visibleCount] (gui::Element const * e) { if (e->isVisible()) ++visibleCount; diff --git a/map/coverage_generator.cpp b/map/coverage_generator.cpp index 6a29394171..4c435d49da 100644 --- a/map/coverage_generator.cpp +++ b/map/coverage_generator.cpp @@ -361,14 +361,20 @@ void CoverageGenerator::ComputeCoverTasks() size_t firstTileForAdd = 0; buffer_vector diff_tiles; diff_tiles.reserve(m_coverageInfo.m_tiles.size() + tiles.size()); +#ifdef _MSC_VER + vs_bug:: +#endif set_difference(m_coverageInfo.m_tiles.begin(), m_coverageInfo.m_tiles.end(), tiles.begin(), tiles.end(), - back_inserter(diff_tiles), CoverageInfo::TTileSet::key_compare()); + back_inserter(diff_tiles), tiles.key_comp()); firstTileForAdd = diff_tiles.size(); +#ifdef _MSC_VER + vs_bug:: +#endif set_difference(tiles.begin(), tiles.end(), m_coverageInfo.m_tiles.begin(), m_coverageInfo.m_tiles.end(), - back_inserter(diff_tiles), CoverageInfo::TTileSet::key_compare()); + back_inserter(diff_tiles), tiles.key_comp()); for (size_t i = 0; i < firstTileForAdd; ++i) tileCache.UnlockTile(diff_tiles[i]->m_rectInfo); diff --git a/map/information_display.cpp b/map/information_display.cpp index 7aa757faf2..38e31fcf41 100644 --- a/map/information_display.cpp +++ b/map/information_display.cpp @@ -133,13 +133,13 @@ void InformationDisplay::setController(gui::Controller * controller) m_controller->AddElement(m_copyrightLabel); shared_ptr task(new AlfaAnimationTask(1.0, 0.0, 0.15, 3.0, m_framework)); - task->AddCallback(anim::Task::EEnded, [this]() + task->AddCallback(anim::Task::EEnded, [this] () { m_controller->RemoveElement(m_copyrightLabel); m_copyrightLabel.reset(); }); - m_copyrightLabel->setAnimated([task]() + m_copyrightLabel->setAnimated([task] () { AlfaAnimationTask * t = static_cast(task.get()); return t->GetCurrentAlfa(); diff --git a/map/map.pro b/map/map.pro index e286ac0493..4a8a279eae 100644 --- a/map/map.pro +++ b/map/map.pro @@ -6,12 +6,7 @@ CONFIG += staticlib warn_on ROOT_DIR = .. - -INCLUDEPATH *= $$ROOT_DIR/3party/protobuf/src -# use expat from the system on linux -!linux*: INCLUDEPATH *= $$ROOT_DIR/3party/expat/lib -INCLUDEPATH *= $$ROOT_DIR/3party/expat/lib - +INCLUDEPATH *= $$ROOT_DIR/3party/protobuf/src $$ROOT_DIR/3party/expat/lib include($$ROOT_DIR/common.pri) diff --git a/map/queued_renderer.cpp b/map/queued_renderer.cpp index f0e8df4843..03d7e095b8 100644 --- a/map/queued_renderer.cpp +++ b/map/queued_renderer.cpp @@ -75,21 +75,22 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum) /// FrameCommands could contain commands from the previous frame if /// the processed pipeline is allowed to be executed partially. - if (m_Pipelines[pipelineNum].m_FrameCommands.empty()) - m_Pipelines[pipelineNum].m_Queue.processList(bind(&QueuedRenderer::PacketsPipeline::FillFrameCommands, &m_Pipelines[pipelineNum], _1, 1)); + PacketsPipeline & ppl = m_Pipelines[pipelineNum]; + if (ppl.m_FrameCommands.empty()) + ppl.m_Queue.processList([&ppl] (list & queueData) { ppl.FillFrameCommands(queueData, 1); }); - cmdProcessed = m_Pipelines[pipelineNum].m_FrameCommands.size(); + cmdProcessed = ppl.m_FrameCommands.size(); list::iterator it; - bool res = !m_Pipelines[pipelineNum].m_FrameCommands.empty(); - bool partialExecution = m_Pipelines[pipelineNum].m_CouldExecutePartially; + bool res = !ppl.m_FrameCommands.empty(); + bool partialExecution = ppl.m_CouldExecutePartially; - graphics::Packet::EType bucketType = m_Pipelines[pipelineNum].m_Type; + graphics::Packet::EType bucketType = ppl.m_Type; - while (!m_Pipelines[pipelineNum].m_FrameCommands.empty()) + while (!ppl.m_FrameCommands.empty()) { - it = m_Pipelines[pipelineNum].m_FrameCommands.begin(); + it = ppl.m_FrameCommands.begin(); if (it->m_command) { it->m_command->setRenderContext(m_RenderContext.get()); @@ -111,7 +112,7 @@ bool QueuedRenderer::RenderQueuedCommands(int pipelineNum) bool isCheckpoint = (it->m_type == graphics::Packet::ECheckPoint); - m_Pipelines[pipelineNum].m_FrameCommands.pop_front(); + ppl.m_FrameCommands.pop_front(); /// if we found a checkpoint instead of frameboundary and this /// pipeline is allowed to be partially executed we are @@ -180,7 +181,7 @@ void QueuedRenderer::PacketsPipeline::FillFrameCommands(list & } } -void QueuedRenderer::CopyQueuedCommands(list &l, list &r) +void QueuedRenderer::CopyQueuedCommands(list & l, list & r) { swap(l, r); } @@ -189,14 +190,12 @@ void QueuedRenderer::CancelQueuedCommands(int pipelineNum) { m_Pipelines[pipelineNum].m_Queue.cancel(); - list l; + list r; - m_Pipelines[pipelineNum].m_Queue.processList(bind(&QueuedRenderer::CopyQueuedCommands, this, _1, ref(l))); + m_Pipelines[pipelineNum].m_Queue.processList([this, &r] (list & l) { CopyQueuedCommands(l, r); }); - for (list::iterator it = l.begin(); it != l.end(); ++it) + for (graphics::Packet const & p : r) { - graphics::Packet p = *it; - if (p.m_command) p.m_command->cancel(); } diff --git a/map/track.cpp b/map/track.cpp index 7ad9123329..a42f10310b 100644 --- a/map/track.cpp +++ b/map/track.cpp @@ -52,7 +52,7 @@ void Track::AddOutline(TrackOutline const * outline, size_t arraySize) { m_outlines.reserve(m_outlines.size() + arraySize); for_each(outline, outline + arraySize, MakeBackInsertFunctor(m_outlines)); - sort(m_outlines.begin(), m_outlines.end(), [](TrackOutline const & l, TrackOutline const & r) + sort(m_outlines.begin(), m_outlines.end(), [] (TrackOutline const & l, TrackOutline const & r) { return l.m_lineWidth > r.m_lineWidth; }); @@ -116,7 +116,7 @@ void Track::CreateDisplayList(graphics::Screen * dlScreen, MatrixT const & matri if (!m_beginSymbols.empty() || !m_endSymbols.empty()) { m2::PointD pivot = pts2.front(); - auto symDrawer = [&dlScreen, &pivot](ClosingSymbol const & symbol) + auto symDrawer = [&dlScreen, &pivot] (ClosingSymbol const & symbol) { dlScreen->drawSymbol(pivot, symbol.m_iconName, symbol.m_position, symbol.m_depth); }; diff --git a/map_server/map_server.pro b/map_server/map_server.pro index edd7cc9f0a..de675a269d 100644 --- a/map_server/map_server.pro +++ b/map_server/map_server.pro @@ -23,6 +23,7 @@ macx* { LIBS *= "-framework Foundation" "-framework CoreWLAN" \ "-framework QuartzCore" "-framework IOKit" } +win32* : LIBS *= -lshell32 SOURCES += main.cpp \ render_context.cpp \ diff --git a/platform/platform_win.cpp b/platform/platform_win.cpp index e7058814e2..271a5f1a07 100644 --- a/platform/platform_win.cpp +++ b/platform/platform_win.cpp @@ -127,7 +127,7 @@ Platform::TStorageStatus Platform::GetWritableStorageStatus(uint64_t neededSize) return STORAGE_DISCONNECTED; } - if (freeSpace.u.LowPart + (freeSpace.u.HighPart << 32) < neededSize) + if (freeSpace.u.LowPart + (static_cast(freeSpace.u.HighPart) << 32) < neededSize) return NOT_ENOUGH_SPACE; return STORAGE_OK; diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 9ced53f567..55aa737f6d 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -50,7 +50,7 @@ MainWindow::MainWindow() : m_locationService(CreateDesktopLocationService(*this) { m_pDrawWidget = new DrawWidget(this); shared_ptr locState = m_pDrawWidget->GetFramework().GetLocationState(); - locState->AddStateModeListener([this](location::State::Mode mode) + locState->AddStateModeListener([this] (location::State::Mode mode) { LocationStateModeChanged(mode); }); @@ -71,7 +71,7 @@ MainWindow::MainWindow() : m_locationService(CreateDesktopLocationService(*this) #else { // create items in the system menu - HMENU menu = ::GetSystemMenu(winId(), FALSE); + HMENU menu = ::GetSystemMenu((HWND)winId(), FALSE); MENUITEMINFOA item; item.cbSize = sizeof(MENUITEMINFOA); item.fMask = MIIM_FTYPE | MIIM_ID | MIIM_STRING; diff --git a/routing/osrm2feature_map.cpp b/routing/osrm2feature_map.cpp index b62d707bff..792a073448 100644 --- a/routing/osrm2feature_map.cpp +++ b/routing/osrm2feature_map.cpp @@ -163,7 +163,7 @@ void OsrmFtSegMapping::DumpSegmentByNode(OsrmNodeIdT nodeId) const void OsrmFtSegMapping::GetOsrmNodes(FtSegSetT & segments, OsrmNodesT & res, volatile bool const & requestCancel) const { - auto addResFn = [&](uint64_t seg, size_t idx, bool forward) + auto addResFn = [&] (uint64_t seg, size_t idx, bool forward) { OsrmNodeIdT const nodeId = GetNodeId(idx); auto it = res.insert({ seg, { forward ? nodeId : INVALID_NODE_ID, diff --git a/routing/osrm2feature_map.hpp b/routing/osrm2feature_map.hpp index 9272d7bafa..43fd11e91f 100644 --- a/routing/osrm2feature_map.hpp +++ b/routing/osrm2feature_map.hpp @@ -27,7 +27,7 @@ public: uint16_t m_pointStart; uint16_t m_pointEnd; - static constexpr uint32_t INVALID_FID = -1; + static const uint32_t INVALID_FID = -1; // No need to initialize something her (for vector). FtSeg() {} diff --git a/routing/osrm_router.cpp b/routing/osrm_router.cpp index bea0d88499..1618b3bc14 100644 --- a/routing/osrm_router.cpp +++ b/routing/osrm_router.cpp @@ -171,8 +171,9 @@ public: OsrmRouter::OsrmRouter(Index const * index, CountryFileFnT const & fn) : m_countryFn(fn), m_pIndex(index), m_isFinalChanged(false), - m_isReadyThread(false), m_requestCancel(false) + m_requestCancel(false) { + m_isReadyThread.clear(); } string OsrmRouter::GetName() const @@ -510,7 +511,7 @@ IRouter::ResultCode OsrmRouter::FindPhantomNodes(string const & fName, m2::Point { Point2PhantomNode getter(m_mapping); - auto processPt = [&](m2::PointD const & p, size_t idx) + auto processPt = [&] (m2::PointD const & p, size_t idx) { getter.SetPoint(p, idx); diff --git a/routing/routing_tests/routing_tests.pro b/routing/routing_tests/routing_tests.pro index 65c554db1e..bd1bb47a33 100644 --- a/routing/routing_tests/routing_tests.pro +++ b/routing/routing_tests/routing_tests.pro @@ -12,7 +12,10 @@ macx-*: LIBS *= "-framework Foundation" "-framework IOKit" include($$ROOT_DIR/common.pri) -linux*: QT *= core +QT *= core + +win32* : LIBS *= -lShell32 + SOURCES += \ ../../testing/testingmain.cpp \ diff --git a/search/indexed_value.hpp b/search/indexed_value.hpp index 87ae4ef9e5..3853823d45 100644 --- a/search/indexed_value.hpp +++ b/search/indexed_value.hpp @@ -64,7 +64,7 @@ void SortByIndexedValue(vector & vec, CompFactory factory) } // prepare combined criteria - for_each(vec.begin(), vec.end(), bind(&IndexedValueBase::SortIndex, _1)); + for_each(vec.begin(), vec.end(), [] (IndexedValueBase & p) { p.SortIndex(); }); // sort results according to combined criteria sort(vec.begin(), vec.end(), &IndexedValueBase::Less); diff --git a/std/algorithm.hpp b/std/algorithm.hpp index 986607a72d..761271018b 100644 --- a/std/algorithm.hpp +++ b/std/algorithm.hpp @@ -31,7 +31,53 @@ using std::replace; using std::reverse; using std::set_union; using std::set_intersection; +// Bug workaround, see http://connect.microsoft.com/VisualStudio/feedbackdetail/view/840578/algorithm-possible-c-compiler-bug-when-using-std-set-difference-with-custom-comperator +#ifdef _MSC_VER +namespace vs_bug +{ +template +OutputIt set_difference( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp) +{ + while (first1 != last1) + { + if (first2 == last2) + return std::copy(first1, last1, d_first); + if (comp(*first1, *first2)) + *d_first++ = *first1++; + else + { + if (!comp(*first2, *first1)) + ++first1; + ++first2; + } + } + return d_first; +} + +template +OutputIt set_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first) +{ + while (first1 != last1) + { + if (first2 == last2) + return std::copy(first1, last1, d_first); + + if (*first1 < *first2) + *d_first++ = *first1++; + else + { + if (! (*first2 < *first1)) + ++first1; + ++first2; + } + } + return d_first; +} + +} // namespace vc_bug +#else using std::set_difference; +#endif using std::set_symmetric_difference; using std::transform; using std::push_heap; diff --git a/std/bind.hpp b/std/bind.hpp index 07c5abfc54..deda8a0113 100644 --- a/std/bind.hpp +++ b/std/bind.hpp @@ -6,7 +6,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include using std::bind; diff --git a/std/common_defines.hpp b/std/common_defines.hpp index 944232a755..7486fa6389 100644 --- a/std/common_defines.hpp +++ b/std/common_defines.hpp @@ -1,4 +1,10 @@ #pragma once +#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES +#endif #define _FILE_OFFSET_BITS 64 + +#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER) + #define CPP11_IS_SUPPORTED +#endif diff --git a/std/function.hpp b/std/function.hpp index 9c3f6d9a4c..d43499e7bc 100644 --- a/std/function.hpp +++ b/std/function.hpp @@ -5,7 +5,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include using std::function; diff --git a/std/shared_ptr.hpp b/std/shared_ptr.hpp index d05e4e0b25..1fefc06f5d 100644 --- a/std/shared_ptr.hpp +++ b/std/shared_ptr.hpp @@ -5,7 +5,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include using std::shared_ptr; diff --git a/std/systime.hpp b/std/systime.hpp index c535b83e50..e32d8c9f84 100644 --- a/std/systime.hpp +++ b/std/systime.hpp @@ -2,6 +2,7 @@ #include "common_defines.hpp" #include "target_os.hpp" +#include "ctime.hpp" #ifdef new #undef new @@ -10,6 +11,9 @@ // for gettimeofday and GetSystemTimeAsFileTime #ifdef OMIM_OS_WINDOWS #include "windows.hpp" + #ifdef OMIM_OS_WINDOWS_MINGW + #define gettimeofday mingw_gettimeofday + #endif #else #include #endif diff --git a/std/unordered_map.hpp b/std/unordered_map.hpp index 19e9588b4c..e6b9fb90f1 100644 --- a/std/unordered_map.hpp +++ b/std/unordered_map.hpp @@ -5,11 +5,6 @@ #undef new #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1600) - // to avoid compilation errors on VS2010 - #define BOOST_NO_0X_HDR_TYPEINDEX -#endif - #include using boost::unordered_map; using boost::unordered_multimap; diff --git a/std/unordered_set.hpp b/std/unordered_set.hpp index c0a69d9eca..2377ed7f2a 100644 --- a/std/unordered_set.hpp +++ b/std/unordered_set.hpp @@ -5,11 +5,6 @@ #undef new #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1600) - // to avoid compilation errors on VS2010 - #define BOOST_NO_0X_HDR_TYPEINDEX -#endif - #include using boost::unordered_set; diff --git a/std/weak_ptr.hpp b/std/weak_ptr.hpp index 842e086efd..e7cba78b95 100644 --- a/std/weak_ptr.hpp +++ b/std/weak_ptr.hpp @@ -5,7 +5,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include using std::weak_ptr; diff --git a/std/windows.hpp b/std/windows.hpp index 714c555889..2003a55ebf 100644 --- a/std/windows.hpp +++ b/std/windows.hpp @@ -3,36 +3,11 @@ #include "target_os.hpp" #ifdef OMIM_OS_WINDOWS -// These defines are moved to common.pri because -// they should be equal for all libraries, even for 3party ones - -//#ifdef _WIN32_WINNT -// #undef _WIN32_WINNT -//#endif -//#define _WIN32_WINNT 0x0501 - -//#ifdef WINVER -// #undef WINVER -//#endif -//#define WINVER 0x0501 - -//#ifndef WIN32_LEAN_AND_MEAN -// #define WIN32_LEAN_AND_MEAN 1 -//#endif - -//#ifdef _WIN32_IE -// #undef _WIN32_IE -//#endif -//#define _WIN32_IE 0x0501 - -//#ifdef NTDDI_VERSION -// #undef NTDDI_VERSION -//#endif -//#define NTDDI_VERSION 0x05010000 - #include #undef min #undef max +//#undef far +//#undef near #endif // OMIM_OS_WINDOWS diff --git a/storage/storage_tests/storage_tests.pro b/storage/storage_tests/storage_tests.pro index cdd86c5b75..a6770eea20 100644 --- a/storage/storage_tests/storage_tests.pro +++ b/storage/storage_tests/storage_tests.pro @@ -13,7 +13,7 @@ include($$ROOT_DIR/common.pri) win32*: LIBS *= -lshell32 win32-g++: LIBS *= -lpthread macx-*: LIBS *= "-framework Foundation" "-framework IOKit" -linux*: QT *= network +linux*|win32-msvc*: QT *= network QT *= core