vim-syntastic / syntastic

Syntax checking hacks for vim
Do What The F*ck You Want To Public License
11.3k stars 1.14k forks source link

#include errors detect c++ in vim #2379

Closed inniestar97 closed 3 years ago

inniestar97 commented 3 years ago

Im using Windows terminal Ubuntu 20.04.3 LTS and gcc version gcc (Ubuntu 9.3.0-17ubuntu~20.04) 9.3.0 g++ version g++ (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0

include 'queue'

include 'iostream'

<<____Here's an error Detection_____

using namespace std;

int main(void) { queue que; << Here's an error detection too. return 0; }

error says that note: 'std::queue' is defined in header '<queue>'; did you forget to '#include <queue>'?

Im using vim-syntastic plugin as above, When I include file (#include ), I get an error saying it is not included and vim-syntastic plugin use like this

let g:syntastic_check_on_wq=0 let g:syntastic_cpp_compiler_options='-std=c++14' let g:syntastic_cpp_compiler='g++' let g:syntastic_cpp_check_header=1

here's on stackoverflow too https://stackoverflow.com/questions/69149083/include-errors-detect-c-in-vim?noredirect=1#comment122216002_69149083

lcd047 commented 3 years ago

You're aware that syntastic is a Vim script and not a C++ linter, right? Please open your test file, set g:syntastic_debug to 1, run the checker, then run :mes and post the output.

inniestar97 commented 3 years ago

First, Thank you so much about your comment,

"test.cpp" 12L, 141C "~/.vim/syntax/cpp.vim" 7L, 163C "test.cpp" 12L, 141C Pattern not found: syntastic_debug=1 "test.cpp" 12L, 141C written syntastic: 59.265460: g:syntastic_version = '3.10.0-27 (Vim 801, Linux)' syntastic: 59.265868: &shell = '/usr/bin/zsh', &shellcmdflag = '-c', &shellpipe = '2>&1| tee', &shellquote = '', &shellredir = '>%s 2>&1', &shelltemp = 1, &shellxquote = '', &autochdir = 0, &shellxescape = '' syntastic: 59.267306: UpdateErrors (auto): default checkers syntastic: 59.276779: CacheErrors: default checkers syntastic: 59.286974: g:syntastic_aggregate_errors = 0 syntastic: 59.287336: getcwd() = '/mnt/c/Users/tkddl/Study/data_structure' syntastic: 59.544762: CacheErrors: Invoking checker: cpp/gcc syntastic: 59.551016: SyntasticMake: called with options: {'postprocess': [], 'errorformat': '%-G%f:%s:,%f:%l:%c: %trror: %m,%f:%l:%c: %tarning: %m,%f:%l:%c: %m,%f:%l: %trror: %m,%f:%l: %tarning: %m,%f:%l: %m', 'makeprg': '''g++'' -x c++ -fsyntax-only -std=c++17 -I. -I.. -Iinclude -Iincludes -I../include -I../includes test.cpp'} syntastic: 60.209730: system: command run in 0.658339s syntastic: 61.469226: getLocList: checker cpp/gcc returned 1 syntastic: 61.469589: getLocList: checker cpp/gcc run in 1.924626s Press ENTER or type command to continue

This is what I saw after follow your comment

lcd047 commented 3 years ago

Now please run this in a terminal and post the output:

cd /mnt/c/Users/tkddl/Study/data_structure
g++ -x c++ -fsyntax-only -std=c++17 -I. -I.. -Iinclude -Iincludes -I../include -I../includes test.cpp
inniestar97 commented 3 years ago

/queue:1:2: error: ‘ELF’ does not name a type; did you mean ‘EOF’? 1 | ELF  >  � @ �y @ 8 @    @ @ @ � �           � �       � �    0 0 0 \ \    �L �\ �\ 8 P     �L �\ �\     8 8 8   X X X D D  S�td 8 8 8 P�td @0 @0 @0 � �  Q�td  R�td �L �\ �\    /lib64/ld-linux-x86-64.so.2    GNU  �     GNU כF���Ed˷��D;D   GNU       �    �e�ms�� C U  r  �  �    �  �    A  #  �  �  a    �  �  �  �  ?  x  �  �   �  G   ; I  0 " @  a  n   libstdc++.so.6 __gmon_start__ _ITM_deregisterTMCloneTable _ITM_registerTMCloneTable _ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE7compareEPKc _ZSt20__throw_length_errorPKc _ZNSirsERi _ZNSolsEi _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1Ev _ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ _ZSt3cin _ZNSt8ios_base4InitD1Ev _ZNSolsEPFRSoS_E _ZSt17__throw_bad_allocv __cxa_begin_catch _ZdlPv _ZNSt8ios_base15sync_with_stdioEb __gxx_personality_v0 _Znwm _ZNSt8ios_base4InitC1Ev __cxa_rethrow _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEED1Ev _ZNSt9basic_iosIcSt11char_traitsIcEE3tieEPSo _ZSt4cout __cxa_end_catch _ZStrsIcSt11char_traitsIcESaIcEERSt13basic_istreamIT_T0_ES7_RNSt7__cxx1112basic_stringIS4_S5_T1_EE libgcc_s.so.1 _Unwind_Resume libc.so.6 __stack_chk_fail __cxa_atexit __cxa_finalize memmove __libc_start_main GCC_3.0 GLIBC_2.4 GLIBC_2.2.5 CXXABI_1.3 GLIBCXX_3.4 GLIBCXX_3.4.21                              �  P&y Y    0 ii  a  ui  k     ӯk  w  t)  �  q��  � �\ � �\  �\ � �_   �_   �_   �_   �_   �_  _      @ a    (  0  8  @  H P X `_ | ^~~ | EOF In file included from test.cpp:1: ./queue:2:835: error: ‘D’ does not name a type 2 | ��h ���������h ��������h ��������h ��������h ��������h ��q������ ��a������h ��Q������h | ^

./queue:2:1592: error: ‘I’ does not name a type 2 | h p x  �  �  �  �  �  � 

                                                                           ��H�H��O  H��t��H��     �5�N  ��%�N   ��h    ���������h   ���������h   ���������h   ��������h   ��������h   ��������h   ��������h   ��q������   ��a������h    ��Q������h
  |

In file included from test.cpp:1: ./queue:84:2: error: expected declaration before ‘}’ token ./queue:84:17: error: expected unqualified-id before ‘|’ token ./queue:111:49: error: ‘Z’ does not name a type ./queue:111:89: error: ‘Z’ does not name a type In file included from test.cpp:1: ./queue:119:627: error: expected declaration before ‘}’ token ./queue:119:658: error: ‘s’ does not name a type In file included from test.cpp:1: ./queue:121:32: error: expected unqualified-id before ‘-’ token In file included from test.cpp:1: ./queue:128:239: error: ‘Y’ does not name a type In file included from /usr/include/c++/9/iosfwd:40, from /usr/include/c++/9/ios:38, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from test.cpp:2: /usr/include/c++/9/bits/postypes.h:98:11: error: ‘ptrdiff_t’ does not name a type 98 | typedef ptrdiff_t streamsize; // Signed integral type | ^~~~~ /usr/include/c++/9/bits/postypes.h:41:1: note: ‘ptrdiff_t’ is defined in header ‘’; did you forget to ‘#include ’? 40 | #include // For mbstate_t +++ |+#include 41 | In file included from /usr/include/c++/9/bits/exception_ptr.h:40, from /usr/include/c++/9/exception:143, from /usr/include/c++/9/ios:39, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from test.cpp:2: /usr/include/c++/9/new:125:50: error: declaration of ‘operator new’ as non-function 125 | _GLIBCXX_NODISCARD void operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^ /usr/include/c++/9/new:125:44: error: ‘size_t’ is not a member of ‘std’; did you mean ‘size_t’? 125 | _GLIBCXX_NODISCARD void operator new(std::size_t) _GLIBCXX_THROW (std::bad_alloc) | ^~ In file included from /usr/include/wchar.h:35, from /usr/include/c++/9/cwchar:44, from /usr/include/c++/9/bits/postypes.h:40, from /usr/include/c++/9/iosfwd:40, from /usr/include/c++/9/ios:38, from /usr/include/c++/9/ostream:38, from /usr/include/c++/9/iostream:39, from test.cpp:2:

.. continued..

as bove, there are so many things like that and so many error on it . I don't know what happens here

lcd047 commented 3 years ago

Do you have a file named queue in the current directory? :smile: Well, fix that and syntastic will start working.

inniestar97 commented 3 years ago

Do you have a file named queue in the current directory? 😄 Well, fix that and syntastic will start working.

oh,, my,, what a shame,... Im sorry for that my stupdity,,, Anyway, Thank you for Your Kindness,,, and HELP,, thank you so much

lcd047 commented 3 years ago

It's a good idea to read :h syntastic-debug to understand what's going on. It's probably an even better idea to use a dedicated plugin for working with C++ files, syntastic is not particularly useful for C / C++, and it's also dead.

inniestar97 commented 3 years ago

It's a good idea to read :h syntastic-debug to understand what's going on. It's probably an even better idea to use a dedicated plugin for working with C++ files, syntastic is not particularly useful for C / C++, and it's also dead.

Yes, I understand Your Replay, And Thank you for your Advice. Really Thank you