Skip to content

Commit

Permalink
1. Оказывается, Far уже можно полноценно собрать в clang. Немного свя…
Browse files Browse the repository at this point in the history
…занной с этим реорганизации в препроцессорных макросах.
  • Loading branch information
alabuzhev committed Nov 14, 2015
1 parent c7e11b2 commit f09f8ad
Show file tree
Hide file tree
Showing 28 changed files with 148 additions and 92 deletions.
9 changes: 6 additions & 3 deletions far/TaskBar.cpp
Expand Up @@ -46,10 +46,13 @@ taskbar::taskbar():
State(TBPF_NOPROGRESS),
pTaskbarList()
{
#ifdef _MSC_VER
assert(__uuidof(*pTaskbarList) == IID_ITaskbarList3);
CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER,
#if COMPILER == C_GCC
IID_ITaskbarList3, IID_PPV_ARGS_Helper(&pTaskbarList)
#else
IID_PPV_ARGS(&pTaskbarList)
#endif
CoCreateInstance(CLSID_TaskbarList, nullptr, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, IID_PPV_ARGS_Helper(&pTaskbarList));
);
}

taskbar::~taskbar()
Expand Down
6 changes: 5 additions & 1 deletion far/changelog
@@ -1,4 +1,8 @@
svs 07.11.2015 00:28:32 +0300 - build 4454
drkns 15.11.2015 01:37:43 +0200 - build 4455

1. Оказывается, Far уже можно полноценно собрать в clang. Немного связанной с этим реорганизации в препроцессорных макросах.

svs 07.11.2015 00:28:32 +0300 - build 4454

1. SQLite 3.9.2

Expand Down
1 change: 1 addition & 0 deletions far/common.hpp
Expand Up @@ -35,6 +35,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// TODO: use separately where required

#include "common/compiler.hpp"
#include "common/preprocessor.hpp"
#include "common/noncopyable.hpp"
#include "common/swapable.hpp"
Expand Down
97 changes: 97 additions & 0 deletions far/common/compiler.hpp
@@ -0,0 +1,97 @@
#pragma once

/*
compiler.hpp
Compiler-specific macros and definitions
*/
/*
Copyright © 2015 Far Group
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// WARNING
// Naive #ifdef _MSC_VER is a BAD WAY to check for Microsoft compiler:
// both Intel and Clang preserve this macro.

// Use #if COMPILER == C_%NAME% to check for specific compiler.
// Use _MSC_VER only for find out its specific version or to check for Microsoft standard library / Windows SDK


// Known compilers
#define C_CL 0
#define C_GCC 1
#define C_INTEL 2
#define C_CLANG 3

#if defined __GNUC__
#define COMPILER C_GCC
#elif defined __clang__
#define COMPILER C_CLANG
#elif defined __INTEL_COMPILER
#define COMPILER C_INTEL
#elif defined _MSC_VER
#define COMPILER C_CL
#else
#error Unknown compiler
#endif

#if COMPILER == C_GCC || COMPILER == C_CLANG
#define STR_PRAGMA(x) _Pragma(#x)
#endif
//----------------------------------------------------------------------------
#if COMPILER == C_CL || COMPILER == C_INTEL
#define PACK_PUSH(n) __pragma(pack(push, n))
#define PACK_POP() __pragma(pack(pop))
#elif COMPILER == C_GCC || COMPILER == C_CLANG
#define PACK_PUSH(n) STR_PRAGMA(pack(n))
#define PACK_POP() STR_PRAGMA(pack())
#endif
//----------------------------------------------------------------------------
#if COMPILER == C_CL || COMPILER == C_INTEL
#define WARNING_PUSH(...) __pragma(warning(push, __VA_ARGS__))
#define WARNING_POP() __pragma(warning(pop))
#elif COMPILER == C_GCC || COMPILER == C_CLANG
#define WARNING_PUSH(...) STR_PRAGMA(GCC diagnostic push)
#define WARNING_POP() STR_PRAGMA(GCC diagnostic pop)
#endif
//----------------------------------------------------------------------------
#if COMPILER == C_CL || COMPILER == C_INTEL
#define WARNING_DISABLE_MSC(id) __pragma(warning(disable: id))
#else
#define WARNING_DISABLE_MSC(id)
#endif
//----------------------------------------------------------------------------
#if COMPILER == C_GCC || COMPILER == C_CLANG
#define WARNING_DISABLE_GCC(id) STR_PRAGMA(GCC diagnostic ignored id)
#else
#define WARNING_DISABLE_GCC(id)
#endif
//----------------------------------------------------------------------------
#if COMPILER == C_CLANG
#define WARNING_DISABLE_CLANG(id) STR_PRAGMA(clang diagnostic ignored id)
#else
#define WARNING_DISABLE_CLANG(id)
#endif
2 changes: 1 addition & 1 deletion far/common/conditional.hpp
Expand Up @@ -49,7 +49,7 @@ template<class T>
struct conditional
{
// already included in VC2013
#if defined _MSC_VER && _MSC_VER < 1800
#if COMPILER == C_CL && _MSC_VER < 1800
struct unspecified_bool
{
struct OPERATORS_NOT_ALLOWED;
Expand Down
2 changes: 1 addition & 1 deletion far/common/enum.hpp
Expand Up @@ -27,7 +27,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if defined _MSC_VER && _MSC_VER < 1700
#if COMPILER == C_CL && _MSC_VER < 1700
#define ENUM(ENUM_NAME) enum ENUM_NAME
#else
#define ENUM(ENUM_NAME) enum ENUM_NAME:int
Expand Down
2 changes: 1 addition & 1 deletion far/common/function_traits.hpp
Expand Up @@ -29,7 +29,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

template <class F> struct return_type;
#define DEFINE_R_TYPE { typedef typename std::remove_const<typename std::remove_reference<R>::type>::type type; };
#if defined _MSC_VER && _MSC_VER < 1800
#if COMPILER == C_CL && _MSC_VER < 1800

template <class R>
struct return_type<R(*)()> DEFINE_R_TYPE
Expand Down
2 changes: 1 addition & 1 deletion far/common/make_vector.hpp
Expand Up @@ -27,7 +27,7 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#if defined _MSC_VER && _MSC_VER < 1800
#if COMPILER == C_CL && _MSC_VER < 1800
template<class T, class T1>
std::vector<T> make_vector(T1&& a1)
{
Expand Down
2 changes: 1 addition & 1 deletion far/common/noncopyable.hpp
Expand Up @@ -41,7 +41,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

class noncopyable
{
#if defined _MSC_VER && _MSC_VER < 1800
#if COMPILER == C_CL && _MSC_VER < 1800
protected:
noncopyable() {};

Expand Down
43 changes: 3 additions & 40 deletions far/common/preprocessor.hpp
Expand Up @@ -27,6 +27,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "compiler.hpp"

#define _ADD_SUFFIX(s, suffix) s ## suffix
#define ADD_SUFFIX(s, suffix) _ADD_SUFFIX(s, suffix)

Expand Down Expand Up @@ -93,46 +95,7 @@ Type& operator=(Type&& rhs) noexcept { swap(rhs); return *this; }
#define SCOPED_ACTION(RAII_type) \
const RAII_type ADD_SUFFIX(scoped_object_, __LINE__)

//----------------------------------------------------------------------------
#ifdef __GNUC__
#define GCC_STR_PRAGMA(x) _Pragma(#x)
#endif
//----------------------------------------------------------------------------
#ifdef __GNUC__
#define PACK_PUSH(n) GCC_STR_PRAGMA(pack(n))
#define PACK_POP() GCC_STR_PRAGMA(pack())
#endif

#ifdef _MSC_VER
#define PACK_PUSH(n) __pragma(pack(push, n))
#define PACK_POP() __pragma(pack(pop))
#endif
//----------------------------------------------------------------------------
#ifdef __GNUC__
#define WARNING_PUSH(...) GCC_STR_PRAGMA(GCC diagnostic push)
#define WARNING_POP() GCC_STR_PRAGMA(GCC diagnostic pop)
#endif

#ifdef _MSC_VER
#define WARNING_PUSH(...) __pragma(warning(push, __VA_ARGS__))
#define WARNING_POP() __pragma(warning(pop))
#endif
//----------------------------------------------------------------------------
#ifdef __GNUC__
#define WARNING_DISABLE_GCC(id) GCC_STR_PRAGMA(GCC diagnostic ignored id)
#else
#define WARNING_DISABLE_GCC(id)
#endif
//----------------------------------------------------------------------------
#ifdef _MSC_VER
#define WARNING_DISABLE_MSC(id) __pragma(warning(disable: id))
#else
#define WARNING_DISABLE_MSC(id)
#endif
//----------------------------------------------------------------------------


#if defined _MSC_VER && _MSC_VER < 1800
#if COMPILER == C_CL && _MSC_VER < 1800
#define DELETED_FUNCTION(...) private: __VA_ARGS__
#else
#define DELETED_FUNCTION(...) __VA_ARGS__ = delete
Expand Down
2 changes: 1 addition & 1 deletion far/common/range_for.hpp
Expand Up @@ -28,7 +28,7 @@ THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// C++11-like range-based for
#if defined _MSC_VER && _MSC_VER < 1700
#if COMPILER == C_CL && _MSC_VER < 1700
#define DECORATED(name) _RANGE_FOR_EMULATION_ ## name ## _
#define f_container DECORATED(container)
#define f_stop DECORATED(stop)
Expand Down
10 changes: 5 additions & 5 deletions far/cpp.hpp
Expand Up @@ -34,6 +34,8 @@ THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#include "common/compiler.hpp"

// already included in VC2012
#if defined _MSC_VER && _MSC_VER < 1700
// In VC++ 2010, there are three overloads of std::to_wstring taking long long, unsigned long long, and long double.
Expand Down Expand Up @@ -138,17 +140,15 @@ namespace std
};
#endif

#if defined _MSC_VER && _MSC_VER < 1900
#if (COMPILER == C_CL && _MSC_VER < 1900) || COMPILER == C_INTEL
// already included in VC2015
#define thread_local __declspec(thread)
#endif

// already included in VC2015
#if defined _MSC_VER && _MSC_VER < 1900
#if !defined __clang__ && !defined __INTEL_COMPILER
#if COMPILER == C_CL && _MSC_VER < 1900
#define noexcept throw()
#endif
#endif

// already included in VC2013
#if defined _MSC_VER && _MSC_VER < 1800
Expand All @@ -167,7 +167,7 @@ using std::wsctoull;
#endif

// already fixed in VC2013
#if defined _MSC_VER && _MSC_VER < 1800 || defined __INTEL_COMPILER
#if (COMPILER == C_CL && _MSC_VER < 1800) || COMPILER == C_INTEL
// operator :: doesn't work with decltype(T) in VC prior to 2013, this trick fixes it:
#define decltype(T) std::enable_if<true, decltype(T)>::type
#endif
1 change: 1 addition & 0 deletions far/far.vcxproj
Expand Up @@ -518,6 +518,7 @@ cl /nologo /c /Fo"$(IntDir)%(Filename)_c++.testobj" /TP api_test.c
</ItemGroup>
<ItemGroup>
<ClInclude Include="common\algorithm.hpp" />
<ClInclude Include="common\compiler.hpp" />
<ClInclude Include="common\null_iterator.hpp" />
<ClInclude Include="common\enum.hpp" />
<ClInclude Include="common\enumerator.hpp" />
Expand Down
3 changes: 3 additions & 0 deletions far/far.vcxproj.filters
Expand Up @@ -1037,5 +1037,8 @@
<ClInclude Include="regex_helpers.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="common\compiler.hpp">
<Filter>Header Files\common</Filter>
</ClInclude>
</ItemGroup>
</Project>
7 changes: 4 additions & 3 deletions far/farexcpt.cpp
Expand Up @@ -595,6 +595,7 @@ void EnableVectoredExceptionHandling()
WARNING_PUSH()

WARNING_DISABLE_MSC(4717) // https://msdn.microsoft.com/en-us/library/97c54274.aspx 'function' : recursive on all control paths, function will cause runtime stack overflow
WARNING_DISABLE_CLANG("-Winfinite-recursion")

static void Test_EXCEPTION_STACK_OVERFLOW(char* target)
{
Expand Down Expand Up @@ -687,22 +688,22 @@ static int ExceptionTestHook(Manager::Key key)
zero_const.i = 1 / zero_const.i;
break;
case 4:
#if defined(_MSC_VER)
#if COMPILER == C_CL || COMPILER == C_INTEL
#ifdef _M_IA64
const int REG_IA64_IntR0 = 1024;
__setReg(REG_IA64_IntR0, 666);
#else
__ud2();
#endif
#elif defined(__GNUC__)
#elif COMPILER == C_GCC || COMPILER == C_CLANG
asm("ud2");
#endif
break;
case 5:
Test_EXCEPTION_STACK_OVERFLOW(nullptr);
break;
case 6:
//refers.d = 1.0/zero_const.d;
zero_const.d = 1.0 / zero_const.d;
break;
case 7:
attach_debugger();
Expand Down
10 changes: 5 additions & 5 deletions far/findfile.cpp
Expand Up @@ -2757,7 +2757,7 @@ bool FindFiles::FindFilesProcess()
SCOPED_ACTION(wakeful);

{
background_searcher BC(this, strFindStr, SearchMode, CodePage, SearchInFirst, AnySetFindList, CmpCase, WholeWords, SearchInArchives, SearchHex, NotContaining, UseFilter);
background_searcher BC(this, strFindStr, SearchMode, CodePage, SearchInFirst, CmpCase, WholeWords, SearchInArchives, SearchHex, NotContaining, UseFilter);

// BUGBUG
m_Searcher = &BC;
Expand Down Expand Up @@ -3192,26 +3192,26 @@ FindFiles::~FindFiles()
}


background_searcher::background_searcher(FindFiles* Owner, const string& FindString,
background_searcher::background_searcher(
FindFiles* Owner,
const string& FindString,
FINDAREA SearchMode,
uintptr_t CodePage,
UINT64 SearchInFirst,
bool AnySetFindList,
bool CmpCase,
bool WholeWords,
bool SearchInArchives,
bool SearchHex,
bool NotContaining,
bool UseFilter):

m_Owner(Owner),
InFileSearchInited(),
m_Autodetection(),

strFindStr(FindString),
SearchMode(SearchMode),
CodePage(CodePage),
SearchInFirst(SearchInFirst),
AnySetFindList(AnySetFindList),
CmpCase(CmpCase),
WholeWords(WholeWords),
SearchInArchives(SearchInArchives),
Expand Down
2 changes: 0 additions & 2 deletions far/findfile.hpp
Expand Up @@ -133,7 +133,6 @@ class background_searcher: noncopyable
FINDAREA SearchMode,
uintptr_t CodePage,
UINT64 SearchInFirst,
bool AnySetFindList,
bool CmpCase,
bool WholeWords,
bool SearchInArchives,
Expand Down Expand Up @@ -187,7 +186,6 @@ class background_searcher: noncopyable
const FINDAREA SearchMode;
const uintptr_t CodePage;
const UINT64 SearchInFirst;
const bool AnySetFindList;
const bool CmpCase;
const bool WholeWords;
const bool SearchInArchives;
Expand Down
2 changes: 1 addition & 1 deletion far/format.hpp
Expand Up @@ -170,7 +170,7 @@ namespace detail
}
}

#if defined _MSC_VER && _MSC_VER < 1800
#if COMPILER == C_CL && _MSC_VER < 1800
#define STRING_FORMAT_IMPL_VTE(TYPENAME_LIST, ARG_LIST, REF_ARG_LIST, FWD_ARG_LIST) \
namespace detail \
{ \
Expand Down

0 comments on commit f09f8ad

Please sign in to comment.