如何配置vim-syntastic以便在C语言中编写python3扩展以避免错误警告?

时间:2018-07-30 18:07:21

标签: python c vim syntastic

我正在使用vim / syntastic编写简单的python3扩展,并且看到一些错误的错误/警告。使用“ sudo python3 setup.ty install”进行的编译工作正常。 gcc是检查器。 pyTFT.c的代码:

#include <Python.h>
static struct PyModuleDef pyTFT = {
    PyModuleDef_HEAD_INIT,
    "pyTFT",
    "",       
    -1,       
    NULL
};

PyMODINIT_FUNC PyInit_pyTFT(void) {
    return PyModule_Create(&pyTFT);
};

setup.py的代码:

from distutils.core import setup, Extension
setup(name='pyTFT', version='0.1', ext_modules=[Extension('pyTFT', ['pyTFT.c'])])

vim中的错误/警告:

[Syntax: line:3 (14)]                                                                                                                                                                    
pyTFT.c|3 col 15 error| variable ‘pyTFT’ has initializer but incomplete type                                                                                                             
pyTFT.c|4 col 5 error| ‘PyModuleDef_HEAD_INIT’ undeclared here (not in a function)
pyTFT.c|4 col 5 warning| excess elements in struct initializer 
pyTFT.c|4 col 5 warning| (near initialization for ‘pyTFT’)
pyTFT.c|5 col 5 warning| excess elements in struct initializer
pyTFT.c|5 col 5 warning| (near initialization for ‘pyTFT’)
pyTFT.c|6 col 5 warning| excess elements in struct initializer
pyTFT.c|6 col 5 warning| (near initialization for ‘pyTFT’)
pyTFT.c|7 col 5 warning| excess elements in struct initializer
pyTFT.c|7 col 5 warning| (near initialization for ‘pyTFT’)
pyTFT.c|9 col 1 warning| excess elements in struct initializer
pyTFT.c|9 col 1 warning| (near initialization for ‘pyTFT’)
pyTFT.c|13 col 5 warning| implicit declaration of function ‘PyModule_Create’ [-Wimplicit-function-declaration]
pyTFT.c|13 col 5 warning| ‘return’ with a value, in function returning void

:vim中的SyntasticInfo:

Syntastic version: 3.9.0-9 (Vim 704, Linux)
Info for filetype: c
Global mode: active
Filetype c is active
The current file will be checked automatically
Available checkers: gcc make
Currently enabled checker: gcc

〜/ .vimrc:

execute pathogen#infect()
autocmd BufWinLeave *.* mkview
autocmd BufWinEnter *.* silent loadview
nmap <F12> :set ts=8 et sw=4 sts=4 <CR>
nmap <C-F12> :set list! <CR>
nmap <C-F11> :SyntasticToggleMode <CR>
set tags=./tags,~/.tags/tags,../tags,../../tags
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
syntax on
filetype on
set tabstop=4
set shiftwidth=4
set expandtab

let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
let g:syntastic_python_python_exec = '/usr/bin/python3.4'
let g:syntastic_c_remove_include_errors = 1

我的〜/ .vimrc中应该有什么摆脱那些错误的错误/警告?

0 个答案:

没有答案