


HDRCHK(1)                 User Commands                 HDRCHK(1)



NAME
     hdrchk - checks a header file for conformance to  headerfile
     standards(PSARC/1991/041).

SYNOPSIS
     hdrchk [filenames]

OUTPUT
     The script outputs violations of  headerfile  standards.  It
     quits after the first violation is found.

OVERVIEW
     hdrchk is a perl script which checks a header file for  con-
     formance  to  PSARC/1991/041.  Actually, it checks for a bit
     more uniformity with respect to uniform formatting  than  is
     specified  by  1991/041,  but these `nits' are not excessive
     and do increase the uniformity and perceived quality of  our
     headers.  1991/041 has also been referred to as KNF format.

     The hdrchk script makes sure that the header  file  has  all
     the following necessary components:

          +o     Format of comments. A comment, when present, when
               on a single line, should be  enclosed by /* and */
               and when multiline, should have each  line  begin-
               ning with an asterisk.

          +o     SCCS keyword. Verifies keywords are used; accepts
               either expanded or unexpanded keywords.

          +o     C++ definitions. Verifies that guards in the form
               of  ifdef  __cplusplus  are  present so a C++ file
               could include the header file  without  explicitly
               using  "extern  C{ ...". Nothing should follow the
               end guard, unless an exception.

          +o     End guards. Verifies that the file has end guards
               in  the form of ifndef variables to prevent multi-
               ple inclusions of the header file.

TEMPLATE
     The template of the standard header file is as follows:

     /*
      * Copyright (c) 1994 by Sun Microsystems, Inc.
      */

     /*
      * Template for header files.
      *
      * This assumes the file is named <sys/foo.h>.  Don't forget
      * to change the _SYS_FOO_H symbol in all three places



SunOS 5.5          Last change: 26 August 1994                  1






HDRCHK(1)                 User Commands                 HDRCHK(1)



      * in this template to reflect the real name of your header
      * file. Also note that this name should reflect the
      * installed path to the file, not its location in
      * the source.
      */

     #ifndef _SYS_FOO_H
     #define _SYS_FOO_H

     #pragma ident   "%Z%%M% %I%     %E% SMI"

     /*
      * Include any headers you depend on.
      */
     #include <sys/bar.h>

     #ifdef  __cplusplus
     extern "C" {
     #endif

     /*
      * Main body of <sys/foo.h> header file goes here.
      */

     #ifdef  __cplusplus
     }
     #endif

     #endif  /* _SYS_FOO_H */


USAGE
     A typical invocation of the script would be as follows:

          example% hdrchk path/of/headerfile.h

     hdrchk reads input from pipe when the input  is  redirected.
     The usage in that situation would be:

          example% cat headerfile.h | hdrchk















SunOS 5.5          Last change: 26 August 1994                  2



