The EXTERN macro
These global variables are prefixed with the macro EXTERN
, for example
EXTERN schar_T *ScreenLines INIT(= NULL);
The
main.c
defines
EXTERN
before it includes
vim.h
which in turn includes
globals.h
.
Thus, when main.c
is compiled, the global variables are defined.
However, globals.h
also contains
#ifndef EXTERN
# define EXTERN extern
# define INIT(x)
#else
# ifndef INIT
# define INIT(x) x
# define DO_INIT
…
# endif
#endif
This allows to externally declare all global variables for all other compilation units.
Windows (win_T) strucures
Vim stores the characteristics of
windows in
win_T
structures.
Regular (that is non-hidden (?)) windows] are stored in a linked list.
*firstwin
points to its first entry, *curwin
to the current window, *lastwin
to the last entry in the linked list.
Buffer related
Linked list of buffers
All
buffers are stored in a linked list.
The global variables firstbuf
and lastbuf
, whose type is buf_T*
point to the first and last buffer, respectively, in the linked list.
FOR_ALL_BUFFERS
FOR_ALL_BUFFERS
is a macro that iterates over all buffers in the linked list. It is defined as
#define FOR_ALL_BUFFERS(buf) for (buf = firstbuf; buf != NULL; buf = buf->b_next)
curbuf
The global variable curbuf
, whose type is also buf_T*
points to the currently active buffer.
Variables that are defined in pathdef.c
Some variables are defined in
src/auto/pathdef.c
(which is generated during the make process):
extern char_u *default_vim_dir; // Location of the global vimrc file (for example /etc, set with the make option VIMRCLOC)
extern char_u *default_vimruntime_dir; // Location of the global runtime files (for example /usr/share/vim, set with the make option VIMRUNTIMEDIR)
extern char_u *all_cflags; // compiler options with which vim sources were compiled.
extern char_u *all_lflags; // linker options with which vim was linked.
extern char_u *compiled_user;
extern char_u *compiled_sys;