← Back to team overview

kicad-developers team mailing list archive

Error in common/tool/tool_manager.cpp with latest OS X C++ library

 

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

Follow ups