Heyo!
I have been using the Syntastic syntax checker plugin for a little while and have been really enjoying the experience except one irritating bug I cannot seem to figure out how to eliminate.
Every time I try to use NULL in my C programs, I get an error signified by the red ">>" and an error bubble saying "use of undeclared identifier 'NULL' [undefined:]"
I have no issues using header files and the program compiles without any issues. It's just visually quite irritating to see a bunch of error flags when I am trying to implement data structures that use NULL pointers or NULL to signify free space.
I am using the gcc compiler and have set the compile options in my vimrc to:
let g:syntastic_c_compiler_options= '-std=c18'
(nothing changes if I remove the line from my vimrc and let it fall back to the default -gnu99
as set by the syntactic syntax-checkers config files in ~/.vim/plugged/syntastic/syntax_checkers/c/gcc.vim
)
Output of :SyntasticInfo
:
Syntastic version: 3.10.0-7 (Vim 802, Linux, GUI)Info for filetype: cGlobal mode: activeFiletype c is activeThe current file will be checked automaticallyAvailable checkers: gcc makeCurrently enabled checkers: gcc
Was hoping someone on here had dealt with a similar issue or had some ideas for a workaround.
Thanks in advance!!
EDIT 1: Syntastic configuration commands in .vimrc
"Syntastic settingslet g:syntastic_always_populate_loc_list = 1let g:syntastic_auto_loc_list = 1let g:syntastic_check_on_open = 1let g:syntastic_check_on_wq = 0"C Settingslet g:syntastic_c_compiler = 'gcc'let g:syntastic_c_checkers=['gcc']let g:syntastic_c_include_dirs=['/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include']let g:syntastic_c_auto_refresh_includes = 1let g:syntastic_c_compiler_options= '-std=c18'let g:syntastic_c_check_header = 1
Adding this to aid in diagnosis, must say thank you very much to everyone giving their input and trying to help me out!
EDIT 2:
I edited the compiler options to :
let g:syntastic_c_compiler_options= '-I/usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/include -Wall -std=c18'
based on a suggestion from @user3629249. Now the undeclared identifier 'NULL' error shows up in the :Errors window (this can be attributed to the -Wall
flag). But progress is progress :). Just need to understand how to configure Syntastic to understand NULL is actually defined in <stddef.h>
.