Thomas Dickey wrote:

> On Feb 9, 12:35=A0am, Tony Mechelynck <[email protected]>
> wrote:
> > > I suspect there's no way to do any of this, but I thought I'd ask befor=
> e
> > > I took a more...cumbersome route. Oh, also what is this declaration
> > > structure:
> > > 2038 static void
> > > 2039 list_func_vars(first)
> > > 2040 int *first;
> > > 2041 {
> > > 2042 if (current_funccal !=3D NULL)
> > > 2043 list_hashtable_vars(&current_funccal->l_vars.dv_hashtab,
> > > 2044 (char_u *)"l:", FALSE, first);
> > > 2045 }
> >
> > > I've never seen that in C before. Declaring variables after the
> > > arguments but before the body?
> >
> > > --Whaledawg
> >
> > It's not variables, it's the arguments: "int *first" here means that
> > "first", the argument, is a pointer to int. I'm told doing it this way
> > rather than "static void list_func_vars(int *first)" makes the source
> > more portable among various C compilers.
> >
> > IIUC, the Vim C source obeys the C89 standard, as shown by this line
> > which I see in the logfile where I saved the stdout/stderr of configure:
> >
> > checking for gcc option to accept ISO C89... none needed
> 
> not exactly "obeys" - Vim is relying on C89 to use pre-standard
> syntax.
> That's called "legacy C", and iirc is not supported in the current
> standard.
> 
> Besides that drawback, using legacy C provides less stringent type-
> checking and other compiler diagnostics.
> 
> It was for that reason that I phased out my own use of legacy C ten
> years ago.
> 
> (of course, if your program has no bugs, you don't need compiler
> checking -
> but I've never seen an interesting program without bugs)

Vim uses "legacy C" in the *.c files, but from that headers are
generated with cproto in the C89 or ANSI-C style.  Protected with a
preprocessor macro, so that this also works on old compilers.
For static functions this is done manually.  E.g. for that
list_func_vars():

        static void list_func_vars __ARGS((int *first));

This way you get backwards compatibility with old compilers, and also
the type checking from new compilers.

A compiler that does not support the "legacy C" style should be
not be called a "C compiler".

-- 
hundred-and-one symptoms of being an internet addict:
63. You start using smileys in your snail mail.

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui