Skip to content

Commit fe63104

Browse files
committed
Fixed code with clang.
1 parent 375d5b2 commit fe63104

17 files changed

+443
-427
lines changed

CMakeLists.txt

Lines changed: 47 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ project(lxgui)
2222

2323
# setup version numbers
2424
set(VERSION_MAJOR 1)
25-
set(VERSION_MINOR 1)
25+
set(VERSION_MINOR 2)
2626

2727
# check compiler version for C++11 features
2828
if(CMAKE_COMPILER_IS_GNUCXX)
@@ -34,12 +34,12 @@ if(CMAKE_COMPILER_IS_GNUCXX)
3434

3535
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion
3636
OUTPUT_VARIABLE GCC_VERSION)
37-
37+
3838
string(REGEX MATCHALL "[0-9]+" GCC_VERSION_COMPONENTS ${GCC_VERSION})
3939
list(GET GCC_VERSION_COMPONENTS 0 GCC_MAJOR)
4040
list(GET GCC_VERSION_COMPONENTS 1 GCC_MINOR)
41-
set(GCC_VERSION ${GCC_MAJOR}.${GCC_MINOR})
42-
41+
set(GCC_VERSION ${GCC_MAJOR}.${GCC_MINOR})
42+
4343
if(GCC_VERSION VERSION_EQUAL 4.6)
4444
message(STATUS "gcc version >= 4.6 (${GCC_VERSION})")
4545
add_definitions(-std=c++0x)
@@ -58,28 +58,54 @@ elseif(MSVC)
5858
if(CMAKE_BUILD_TYPE MATCHES Debug)
5959
add_definitions(/Zi)
6060
endif()
61-
62-
if(MSVC_VERSION VERSION_EQUAL 1600)
63-
add_definitions(/DNO_CPP11_EXPLICIT_CONV)
64-
add_definitions(/DNO_CPP11_DELETE_FUNCTION)
65-
add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT)
66-
add_definitions(/DNO_CPP11_CONSTEXPR)
67-
add_definitions(/DNO_CPP11_UNICODE_LITTERAL)
68-
add_definitions(/D_CRT_SECURE_NO_DEPRECATE)
61+
62+
add_definitions(/DNO_CPP11_EXPLICIT_CONV)
63+
add_definitions(/DNO_CPP11_DELETE_FUNCTION)
64+
add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT)
65+
add_definitions(/DNO_CPP11_CONSTEXPR)
66+
add_definitions(/DNO_CPP11_UNICODE_LITTERAL)
67+
add_definitions(/D_CRT_SECURE_NO_DEPRECATE)
68+
69+
if(NOT (MSVC_VERSION VERSION_LESS 1600))
6970
message(STATUS "Using MSVC 2010: some C++11 features are not supported by this compiler. Workarounds are used but never perfectly mimic the C++11 code.")
70-
elseif(MSVC_VERSION VERSION_GREATER 1600)
71-
add_definitions(/DNO_CPP11_EXPLICIT_CONV)
72-
add_definitions(/DNO_CPP11_DELETE_FUNCTION)
73-
add_definitions(/DNO_CPP11_FUNCTION_TEMPLATE_DEFAULT)
74-
add_definitions(/DNO_CPP11_CONSTEXPR)
75-
add_definitions(/DNO_CPP11_UNICODE_LITTERAL)
76-
add_definitions(/D_CRT_SECURE_NO_DEPRECATE)
77-
message(STATUS "Using MSVC > 2010: some C++11 features are not supported by this compiler. Workarounds are used but never perfectly mimic the C++11 code.")
7871
else()
7972
message(ERROR ": lxgui requires advanced features from the C++11 norm that are only available with MSVC 2010 or higher (your version: ${MSVC_VERSION}). Please upgrade your compiler.")
8073
endif()
74+
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
75+
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 2.99)
76+
message(STATUS "clang version >= 3.0 (${CMAKE_CXX_COMPILER_VERSION})")
77+
else()
78+
message(ERROR ": lxgui requires advanced features from the C++11 norm that are only available with clang 3.0 or higher (your version: ${CMAKE_CXX_COMPILER_VERSION}). Please upgrade your compiler.")
79+
endif()
80+
81+
add_definitions(-Weverything)
82+
add_definitions(-Wno-c++98-compat-pedantic)
83+
add_definitions(-Wno-c++98-compat)
84+
add_definitions(-Wno-unused-parameter)
85+
add_definitions(-Wno-sign-conversion)
86+
add_definitions(-Wno-conversion)
87+
add_definitions(-Wno-missing-variable-declarations)
88+
add_definitions(-Wno-missing-prototypes)
89+
add_definitions(-Wno-padded)
90+
add_definitions(-Wno-float-equal)
91+
add_definitions(-Wno-unused-variable)
92+
add_definitions(-Wno-global-constructors)
93+
add_definitions(-Wno-exit-time-destructors)
94+
add_definitions(-Wno-weak-vtables)
95+
add_definitions(-Wno-covered-switch-default)
96+
add_definitions(-Wno-documentation-unknown-command)
97+
add_definitions(-Wno-unneeded-internal-declaration)
98+
add_definitions(-Wno-unused-function)
99+
add_definitions(-Wno-unused-macros)
100+
add_definitions(-Wno-switch-enum)
101+
if(CMAKE_BUILD_TYPE MATCHES Debug)
102+
add_definitions(-g)
103+
else()
104+
add_definitions(-O3)
105+
endif()
106+
add_definitions(-std=c++11)
81107
else()
82-
message(STATUS "Warning: your compiler has not been setup by the CMake script, do not expect it to work")
108+
message(WARNING "Warning: your compiler has not been setup by the CMake script, do not expect it to work")
83109
endif()
84110

85111
# set OS preprocessor defines

gui/src/gui_frame.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,9 +1070,9 @@ void frame::notify_script_defined(const std::string& sScriptName, bool bDefined)
10701070

10711071
if (bDefined)
10721072
{
1073-
std::map<std::string, handler>::iterator iter = lDefinedHandlerList_.find(sScriptName);
1074-
if (iter != lDefinedHandlerList_.end())
1075-
lDefinedHandlerList_.erase(iter);
1073+
std::map<std::string, handler>::iterator iter2 = lDefinedHandlerList_.find(sScriptName);
1074+
if (iter2 != lDefinedHandlerList_.end())
1075+
lDefinedHandlerList_.erase(iter2);
10761076

10771077
lDefinedScriptList_[sCutScriptName] = "";
10781078
} else
@@ -1330,14 +1330,14 @@ void frame::on(const std::string& sScriptName, event* pEvent)
13301330
// that will print the actual line numbers in the XML file.
13311331
pErrorFunc = pLua->get_lua_error_function();
13321332

1333-
std::map<std::string, script_info>::const_iterator iter = lXMLScriptInfoList_.find(sScriptName);
1334-
if (iter != lXMLScriptInfoList_.end())
1333+
std::map<std::string, script_info>::const_iterator iter2 = lXMLScriptInfoList_.find(sScriptName);
1334+
if (iter2 != lXMLScriptInfoList_.end())
13351335
{
13361336
sFile = pLua->get_global_string("_xml_file_name", false, "");
13371337
uiLineNbr = pLua->get_global_int("_xml_line_nbr", false, 0);
13381338

1339-
pLua->push_string(iter->second.sFile); pLua->set_global("_xml_file_name");
1340-
pLua->push_number(iter->second.uiLineNbr); pLua->set_global("_xml_line_nbr");
1339+
pLua->push_string(iter2->second.sFile); pLua->set_global("_xml_file_name");
1340+
pLua->push_number(iter2->second.uiLineNbr); pLua->set_global("_xml_line_nbr");
13411341

13421342
pLua->set_lua_error_function(l_xml_error);
13431343
}
@@ -1561,7 +1561,7 @@ void frame::set_parent(uiobject* pParent)
15611561
gui::out << gui::error << "gui::" << lType_.back() << " : Cannot call set_parent(this)." << std::endl;
15621562
return;
15631563
}
1564-
1564+
15651565
if (pParent != pParent_)
15661566
{
15671567
if (!pParentFrame_ && uiID_ != uint(-1))

gui/src/gui_frame_glues.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ int lua_frame::_register_event(lua_State* pLua)
722722
int lua_frame::_register_for_drag(lua_State* pLua)
723723
{
724724
if (!check_parent_())
725-
return 0;
725+
return 0;
726726

727727
lua::function mFunc("Frame:register_for_drag", pLua);
728728
mFunc.add(0, "button 1", lua::TYPE_STRING, true);
@@ -733,7 +733,7 @@ int lua_frame::_register_for_drag(lua_State* pLua)
733733
std::vector<std::string> lButtonList;
734734
for (uint i = 0; i < 3; ++i)
735735
{
736-
if (mFunc.is_provided(i))
736+
if (mFunc.is_provided(i))
737737
lButtonList.push_back(mFunc.get(i)->get_string());
738738
else
739739
break;
@@ -891,7 +891,7 @@ int lua_frame::_set_backdrop_color(lua_State* pLua)
891891
}
892892
}
893893
else
894-
mColor = color(mFunc.get(0)->get_string());
894+
mColor = color(mFunc.get(0)->get_string());
895895

896896
pBackdrop->set_background_color(mColor);
897897
}
@@ -1121,18 +1121,18 @@ int lua_frame::_set_script(lua_State* pLua)
11211121
std::string sScriptName = mFunc.get(0)->get_string();
11221122
if (pFrameParent_->can_use_script(sScriptName))
11231123
{
1124-
lua::state* pLua = mFunc.get_state();
1124+
lua::state* pState = mFunc.get_state();
11251125
utils::wptr<lua::argument> pArg = mFunc.get(1);
11261126
if (pArg->is_provided() && pArg->get_type() == lua::TYPE_FUNCTION)
11271127
{
1128-
pLua->push_value(pArg->get_index());
1129-
pLua->set_global(pFrameParent_->get_name() + ":" + sScriptName);
1128+
pState->push_value(pArg->get_index());
1129+
pState->set_global(pFrameParent_->get_name() + ":" + sScriptName);
11301130
pFrameParent_->notify_script_defined(sScriptName, true);
11311131
}
11321132
else
11331133
{
1134-
pLua->push_nil();
1135-
pLua->set_global(pFrameParent_->get_name() + ":" + sScriptName);
1134+
pState->push_nil();
1135+
pState->set_global(pFrameParent_->get_name() + ":" + sScriptName);
11361136
pFrameParent_->notify_script_defined(sScriptName, false);
11371137
}
11381138
}

0 commit comments

Comments
 (0)