{"id":414,"date":"2018-08-04T17:54:59","date_gmt":"2018-08-04T17:54:59","guid":{"rendered":"https:\/\/www.haoyuan.info\/?p=414"},"modified":"2018-08-04T17:55:53","modified_gmt":"2018-08-04T17:55:53","slug":"vim-ide%e7%8e%af%e5%a2%83-youcompleteme%e8%ae%be%e7%bd%ae-ycm_extra_conf-py-%e8%a7%a3%e5%86%b3no-type-name-xxx%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/haoyuan.info\/?p=414","title":{"rendered":"Vim IDE\u73af\u5883 YouCompleteMe\u8bbe\u7f6e.ycm_extra_conf.py \u89e3\u51b3no type name xxx\u95ee\u9898"},"content":{"rendered":"<h2>\u95ee\u9898\u63cf\u8ff0<\/h2>\n<p>\u5728macOS\u4e0a\u914d\u7f6e\u5b8cYouCompleteMe\u540e\u542f\u52a8Vim\uff0c\u5728\u67e5\u770bC++\u6587\u4ef6\u65f6\u5076\u5c14\u4f1a\u62a5\u4e00\u4e9b\u5947\u602a\u7684\u9519\u8bef\uff0c\u5982<code>no type name vector&lt;int&gt;<\/code><br \/>\n\u5b9e\u9645\u4e0a\u8fd8\u662f~\/.vim\/bundle\/YouCompleteMe\u6587\u4ef6\u5939\u4e0b\u7684.ycm_extra_conf.py\u6587\u4ef6\u4e2d\u7684flag\u6570\u7ec4\u6ca1\u8bbe\u7f6e\u597d\u3002<\/p>\n<p>\u8fd9\u4e2a\u6570\u7ec4\u662f\u6709\u987a\u5e8f\u8981\u6c42\u7684\uff0c\u56e0\u6b64\u8c03\u6574\u8bbe\u7f6e\u987a\u5e8f\u5c31\u53ef\u4ee5\u6b63\u5e38\u8fd0\u884c\u4e86<br \/>\n\u8fd9\u91cc\u7ed9\u51fa\u6211\u7684\u4f8b\u5b50\uff0c\u6839\u636e\u81ea\u5df1\u7684\u73af\u5883\u5355\u72ec\u8fdb\u884c\u8c03\u6574<\/p>\n<h2>.ycm_extra_conf.py samle<\/h2>\n<pre><code class=\"language-python  line-numbers\"># Copyright (C) 2014 Google Inc.\n#\n# This file is part of ycmd.\n#\n# ycmd is free software: you can redistribute it and\/or modify\n# it under the terms of the GNU General Public License as published by\n# the Free Software Foundation, either version 3 of the License, or\n# (at your option) any later version.\n#\n# ycmd is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU General Public License for more details.\n#\n# You should have received a copy of the GNU General Public License\n# along with ycmd.  If not, see &lt;http:\/\/www.gnu.org\/licenses\/&gt;.\n\nimport os\nimport ycm_core\n\n# These are the compilation flags that will be used in case there's no\n# compilation database set (by default, one is not set).\n# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.\nflags = [\n'-Wall',\n'-Wextra',\n'-Werror',\n'-fexceptions',\n'-DNDEBUG',\n# THIS IS IMPORTANT! Without a \"-std=&lt;something&gt;\" flag, clang won't know which\n# language to use when compiling headers. So it will guess. Badly. So C++\n# headers will be compiled as C headers. You don't want that so ALWAYS specify\n# a \"-std=&lt;something&gt;\".\n# For a C project, you would set this to something like 'c99' instead of\n# 'c++11'.\n'-std=c++11',\n# ...and the same thing goes for the magic -x option which specifies the\n# language that the files to be compiled are written in. This is mostly\n# relevant for c++ headers.\n# For a C project, you would set this to 'c' instead of 'c++'.\n'-x',\n'c++',\n'-isystem',\n'\/usr\/local\/Cellar\/gcc\/8.2.0\/include\/c++\/8.2.0',\n'-isystem',\n'\/usr\/local\/Cellar\/gcc\/8.2.0\/include\/c++\/8.2.0\/x86_64-apple-darwin17.7.0',\n'-isystem',\n'\/usr\/include',\n'-isystem',\n'\/usr\/local\/include',\n'-isystem',\n'\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/..\/lib\/c++\/v1',\n'-isystem',\n'\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/include'\n]\n\n\n# Set this to the absolute path to the folder (NOT the file!) containing the\n# compile_commands.json file to use that instead of 'flags'. See here for\n# more details: http:\/\/clang.llvm.org\/docs\/JSONCompilationDatabase.html\n#\n# Most projects will NOT need to set this to anything; you can just change the\n# 'flags' list of compilation flags.\ncompilation_database_folder = ''\n\nif os.path.exists( compilation_database_folder ):\n  database = ycm_core.CompilationDatabase( compilation_database_folder )\nelse:\n  database = None\n\nSOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]\n\ndef DirectoryOfThisScript():\n  return os.path.dirname( os.path.abspath( __file__ ) )\n\n\ndef IsHeaderFile( filename ):\n  extension = os.path.splitext( filename )[ 1 ]\n  return extension in [ '.h', '.hxx', '.hpp', '.hh' ]\n\n\ndef GetCompilationInfoForFile( filename ):\n  # The compilation_commands.json file generated by CMake does not have entries\n  # for header files. So we do our best by asking the db for flags for a\n  # corresponding source file, if any. If one exists, the flags for that file\n  # should be good enough.\n  if IsHeaderFile( filename ):\n    basename = os.path.splitext( filename )[ 0 ]\n    for extension in SOURCE_EXTENSIONS:\n      replacement_file = basename + extension\n      if os.path.exists( replacement_file ):\n        compilation_info = database.GetCompilationInfoForFile(\n          replacement_file )\n        if compilation_info.compiler_flags_:\n          return compilation_info\n    return None\n  return database.GetCompilationInfoForFile( filename )\n\n\n# This is the entry point; this function is called by ycmd to produce flags for\n# a file.\ndef FlagsForFile( filename, **kwargs ):\n  if not database:\n    return {\n      'flags': flags,\n      'include_paths_relative_to_dir': DirectoryOfThisScript()\n    }\n\n  compilation_info = GetCompilationInfoForFile( filename )\n  if not compilation_info:\n    return None\n\n  # Bear in mind that compilation_info.compiler_flags_ does NOT return a\n  # python list, but a \"list-like\" StringVec object.\n  return {\n    'flags': list( compilation_info.compiler_flags_ ),\n    'include_paths_relative_to_dir': compilation_info.compiler_working_dir_\n  }\n\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\u63cf\u8ff0 \u5728macOS\u4e0a\u914d\u7f6e\u5b8cYouCompleteMe\u540e\u542f\u52a8Vim\uff0c\u5728\u67e5\u770bC++\u6587\u4ef6\u65f6\u5076\u5c14\u4f1a\u62a5\u4e00\u4e9b\u5947\u602a\u7684\u9519\u8bef [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[19,7,1],"tags":[],"class_list":["post-414","post","type-post","status-publish","format-standard","hentry","category-19","category-7","category-1"],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8UC2c-6G","jetpack_likes_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts\/414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=414"}],"version-history":[{"count":0,"href":"https:\/\/haoyuan.info\/index.php?rest_route=\/wp\/v2\/posts\/414\/revisions"}],"wp:attachment":[{"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/haoyuan.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}