<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi,<div><br></div><div>After watching Chandler Carruth's <a href="http://channel9.msdn.com/Events/GoingNative/2013/The-Care-and-Feeding-of-C-s-Dragons">http://channel9.msdn.com/Events/GoingNative/2013/The-Care-and-Feeding-of-C-s-Dragons</a> I decided to try the format and modernize examples in the middle of his presentation. After installing the latest LLVM suite, all examples without #include files work fine, both in clang-format and clang-modernize. Very impressive.</div><div><br></div><div>Using the native (Apple, Xcode) toolchain, I can cmake, make and run the example programs in a build directory directly under the source directory, e,g. clang-tools/vector/build under clang-tools/vector which contains vector.cpp and CMakeLists.txt.</div><div><br></div><div>But clang-modernize will fail *if* it contains a template based #include, e.g. Chandler's loop-convert example based on a small vector<int> loop.</div><div>Somehow I can't figure out how to specify the right flags for the compiler/linker in cmakelist.txt.</div><div><br></div><div>Any pointers appreciated!</div><div><br></div><div>Thanks,</div><div><div apple-content-edited="true">
<span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px;"><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>Rob J. Goedman</div><div><a href="mailto:goedman@icloud.com">goedman@icloud.com</a></div><div><br></div><div>------------/clang-tools/vector/vector.cpp------------</div><div><br></div></div></span><div apple-content-edited="true">#include <vector></div><div apple-content-edited="true">#include <iostream></div><div apple-content-edited="true"><br></div><div apple-content-edited="true">int sum(const std::vector<int> &numbers) {</div><div apple-content-edited="true">  int result = 0;</div><div apple-content-edited="true">  for (std::vector<int>::const_iterator it = numbers.begin();</div><div apple-content-edited="true">       it != numbers.end(); ++it) {</div><div apple-content-edited="true">    result += *it;</div><div apple-content-edited="true">  }</div><div apple-content-edited="true">  return result;</div><div apple-content-edited="true">}</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">int main() {</div><div apple-content-edited="true">  std::vector<int> nums = { 1, 5, 6, 38 };</div><div apple-content-edited="true">  std::cout << sum(nums) << std::endl;</div><div apple-content-edited="true">}</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">-------------/clang-tools/vector/CMakeLists.Txt</div><div apple-content-edited="true"><br></div><div apple-content-edited="true"><div apple-content-edited="true">project(foundations)</div><div apple-content-edited="true">cmake_minimum_required(VERSION 2.8)</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">include_directories($ENV{GMOCK_HOME}/include $ENV{GMOCK_HOME}/gtest/include)</div><div apple-content-edited="true">link_directories($ENV{GMOCK_HOME}/mybuild $ENV{GMOCK_HOME}/gtest/mybuild)</div><div apple-content-edited="true">add_definitions(-stdlib=libc++ -std=c++11)</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">set(sources </div><div apple-content-edited="true">  vector.cpp</div><div apple-content-edited="true">)</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">add_executable(test ${sources})</div><div apple-content-edited="true">target_link_libraries(test pthread)</div><div apple-content-edited="true">target_link_libraries(test gmock)</div><div apple-content-edited="true">target_link_libraries(test gtest)</div><div apple-content-edited="true"><br></div><div apple-content-edited="true">-----------------------</div><div apple-content-edited="true"><br></div><div apple-content-edited="true"><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">robs-15inch-2:build rob$ rm -rf *</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">robs-15inch-2:build rob$ cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON ..</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- The C compiler identification is Clang 5.0.0</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- The CXX compiler identification is Clang 5.0.0</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Check for working C compiler: /usr/bin/cc</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Check for working C compiler: /usr/bin/cc -- works</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Detecting C compiler ABI info</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Detecting C compiler ABI info - done</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Check for working CXX compiler: /usr/bin/c++</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Detecting CXX compiler ABI info</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Detecting CXX compiler ABI info - done</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Configuring done</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Generating done</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">-- Build files have been written to: /Users/rob/Projects/Languages/Cpp/clang_tools/vector/build</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">robs-15inch-2:build rob$ make</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; color: rgb(209, 54, 207); background-color: rgb(255, 248, 213);">Scanning dependencies of target test</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; color: rgb(45, 184, 32); background-color: rgb(255, 248, 213);"><span style="color: #000000">[100%] </span>Building CXX object CMakeFiles/test.dir/vector.cpp.o</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; color: rgb(192, 52, 29); background-color: rgb(255, 248, 213);">Linking CXX executable test</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">[100%] Built target test</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">robs-15inch-2:build rob$ ./test</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">50</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">robs-15inch-2:build rob$ clang-format -style LLVM -i ../vector.cpp </div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">robs-15inch-2:build rob$ clang-modernize -summary -p . -include ..</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">Parse: /Users/rob/Projects/Languages/Cpp/clang_tools/vector</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">/Users/rob/Projects/Languages/Cpp/clang_tools/vector/vector.cpp:1:10: <span style="color: #c0341d">fatal error: </span>'vector' file not found</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">#include <vector></div><div style="margin: 0px; font-size: 10px; font-family: Monaco; color: rgb(45, 184, 32); background-color: rgb(255, 248, 213);">         ^</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">1 error generated.</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">Error while processing /Users/rob/Projects/Languages/Cpp/clang_tools/vector/vector.cpp.</div><div style="margin: 0px; font-size: 10px; font-family: Monaco; background-color: rgb(255, 248, 213);">Error encountered during translation.</div><div><br></div></div></div></div></div></body></html>