Martin Roehrig <[EMAIL PROTECTED]> wrote:
        ---------------- myheader.h --------------
        typedef int mytype;
        ---------------- mycode_1.c --------------
        #include "myheader.h"
        ---------------- mycode_2.c --------------
        #include "MYHEADER.H"
        > splint *.c
        Splint --- 11 Feb 2002
        MYHEADER.H(1,13): Datatype mytype defined more than once
          A function or variable is redefined. One of the declarations should use
          extern. (Use -redef to inhibit warning)
           myheader.h(1,13): Previous definition of mytype
The wording of this message needs improving, as putting 'extern' into
a 'typedef' is quite illegal.

My preferred method for handling the duplicate inclusion problem is

        ---------------- myheader.h ----------------
        #ifndef MYHEADER_H_
        #define MYHEADER_H_ 20020422 /* or whatever the date is */
        ... usual contents ...

Do _not_ put the underscore at the beginning, because that puts you in
reserved name land, and C vendors do use sometimes quite surprising
reserved names.  Putting the date or a version number there is a really
good idea because then other files can do
        #include "myheader.h"
        #if MYHEADER_H_ < 20020422
        #error This file needs version 20020422 or later of myheader.h

Note that using the same file name with different case patterns is
a _great_ recipe for porting problems.  Perhaps splint should warn
if that happens
    Warning: file may be included under two different names:
        <lino1> myheader.h
        <lino2> MYHEADER.H

Reply via email to