On 07/17/2014 05:22 AM, Michael Narigon wrote:
All, I am trying to compile KiCad with the latest compilers and libraries from Apple. I am getting an error in common/tool/tool_manager.cpp at line 180.[ 86%] Building CXX object common/CMakeFiles/common.dir/tool/tool_manager.cpp.o In file included from /Users/mnarigon/Projects/kicad-dev/kicad-source/common/tool/tool_manager.cpp:27: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/deque:912:49: error: invalid application of 'sizeof' to an incomplete type 'value_type' (aka 'TOOL_MANAGER::TOOL_STATE') static const difference_type __block_size = sizeof(value_type) < 256 ? 4... /Users/mnarigon/Projects/kicad-dev/kicad-source/common/tool/tool_manager.cpp:180:28: note: in instantiation of template class 'std::__1::stack<TOOL_MANAGER::TOOL_STATE, std::__1::deque<TOOL_MANAGER::TOOL_STATE, std::__1::allocator<TOOL_MANAGER::TOOL_STATE> > >' requested here std::stack<TOOL_STATE> stateStack; ^ /Users/mnarigon/Projects/kicad-dev/kicad-source/common/tool/tool_manager.cpp:56:22: note: definition of 'TOOL_MANAGER::TOOL_STATE' is not complete until the closing '}' struct TOOL_MANAGER::TOOL_STATE What is is complaining about is the std:stack stateStack is taking a template parameter TOOL_STATE. However, at this point we are still in the definition of TOOL_STATE so that TOOL_STATE is an incomplete type so the sizeof in the header isn’t working. Looking at the code, I don’t see a simple way to fix it. Apple’s latest library is compliant to the C++ standard so I suspect the next version of g++ will also complain about this usage. Any thoughts? Maybe use a pointer to the state in the stack and then use new/copy/delete. Michael
Thank you for the information. Could you try the attached patch? If everything is fine, I will push it to the product branch.
Regards, Orson
>From 6cb9d59999f40e64724f2575423ef2099d77c8f3 Mon Sep 17 00:00:00 2001 From: Maciej Suminski <[email protected]> Date: Thu, 17 Jul 2014 09:25:49 +0200 Subject: [PATCH] Fix MacOS build. --- common/tool/tool_manager.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index cf64603..6aec0a9 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -145,7 +145,7 @@ struct TOOL_MANAGER::TOOL_STATE */ void Push() { - stateStack.push( *this ); + stateStack.push( new TOOL_STATE( *this ) ); clear(); } @@ -162,7 +162,8 @@ struct TOOL_MANAGER::TOOL_STATE if( !stateStack.empty() ) { - *this = stateStack.top(); + *this = *stateStack.top(); + delete stateStack.top(); stateStack.pop(); return true; @@ -177,7 +178,7 @@ struct TOOL_MANAGER::TOOL_STATE private: ///> Stack preserving previous states of a TOOL. - std::stack<TOOL_STATE> stateStack; + std::stack<TOOL_STATE*> stateStack; ///> Restores the initial state. void clear() -- 1.9.1
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

