:








          - 

                    "        "













                  

                     

                        /P 2.1










                     

                          

                            LINT












                           

                            1988

















          -
    lint.    lint.
































































      lint          lint,
    -,  
  .      -
 lint      -
  .       
    ,   
,  ..   ,      
       
.     lint  -
   ,     -
 .   lint    -
         
.

        lint  -  
 ,    .  
      -    
.       ,  -
           
,     .  -
 lint        
,        
.

             
lint,      ,   -
        -   -
.

1.   

     ,        
file1.c,  file2.c,     -
 .   

    lint file1.c file2.c

 ,    -
     .   lint -
        
,    -  (     
 ).  

    lint -p file1.c file2.c

  ,     , ,
       
  .

       -p  -h        
             


                           - 3 -










, ,  ,      -
.     -hp       
.

             
,    ,   -
         
   -.    
   lint.

2.   

      ,    ,    -
  lint,  .  ,   ,
  -       
  ,     -
.     ,      -  
  exit,    " ",
   .

      ,    lint
     .    
   ,         .
     ,   lint -
,     .          
 ,    .

      lint      
 .    "   -
"   ,       
,            
 .        ,
         -
  ,    
 .

         ,      
 ,   lint.

3.     

            ,
       
  .   ,    
     ,   -
        .  
""         .
  ,      
          
:         
,        ,    -    
!



                           - 4 -










      lint       -
,     -  .  -
  ,     
  extern,       ;
, 

    extern float sin();

   ,   sin 
  .  ,     -
   .  ,      
     -
;        -x
  lint.

           ,   
          -
,         -
     .   -v -
       -
.         
  ,    , -
    ,    ,   -
;        -
    ,   -
.

      ,       
     ,  .
     lint  ,    ,
      ,     -
.           -
     , ,  -
   ,       .
          
 -u.

4.       

       lint         
      -
.        ;    
      
,  ,        
.    lint   -
 (     ), 
         ,
     .   
,            
,       
         -
.



                           - 5 -










             
       -
,         
   .   ,  lint 
   ,     -
,          -
  (,      
 goto).      
  ,       
      .  
         
  ,   , 
 ,      .

            
    ,  -
  ,     .
         , 
     .

5.   

      lint     
    .     -
  ,      
  goto,  break,  continue,   return.  
   ,     -
         ;   
     while(1)
  for(;;).   lint    ,  -
     ;    -
     ,    
     ,    - 
.

      ,     -
    lint    " ": 
  ,  ,    
       .  , 
exit        
,      lint.  
       -
  (. ).

         ,   -
      lint:   -  
break.  ,  ,    yacc[2]
, , lex[3],     -
   break.       -O    -
      -
  .   ,    
        ,    
       .   ..      


                           - 6 -










          lint.   
   ,   lint   
-b.

6.   

        ,    
;      "-
" ,    .    lint
    .

         ,      
,   

            return();
    
            return;

   ;  lint   
function  name  contains  ruturn(e)  and return" (" 
 name  return()  return").   
     ,  -
     ,  -
    .     -
   :

    f(a){
            if(a) return(3);
            g
        }

,   a ,   f   g 
  ,    -
 ;     lint.   
   g,  exit,   , -
    ,      
 .

                
   ;    
   "" ,   -
 lint.

         lint   ,
          ,  ,
,  ( )  .    -
      ,   
   .    
   ,    -
            (,  
    ).




                           - 7 -










      ,     -
  ,     -
,  .      .
  ,      -
  "" ;   ,    
   ,  .

      lint       
        ,  .
     :
  ,  ,
   ,  
      .

           ,  
    .       
,   (?:)     .
    char, short, int, long, unsigned,float
 double     .     
  ,  , , -
         
.      ,   
    ->>    ,  
      . ()    
     ,   -
    .      
  .

           -
          .  
float  double  ,       char,
short, int  unsigned.   ,   -
   .     -
,       
    .

         ,      
         -
  ;            
   =, ==, !=,    -
 .

7.   

             -
         -
.    

    p=1;

 p -   .   lint  -
    .   



                           - 8 -










    p = (char*) 1;

         -
      .  , -
         
  .       
  lint,       
    .     ,   
           -
.    -c     -
 .    -c ,    
    ,     
       
,           
.

8.   ,  .

        -1420      
,       -128  127.    
        
.   lint    
      .   -
, 

    char c;
          ...
    if ((c=getchar())<0)...

   -1420,       ,
        .
        ,
   getchar    .  
   lint    "nonportable
character  comparison"  ("    -
").          ;  
         ,
        
.     ,    -
             .
      ,   ,
  int,     3;   -
  ,           
unsigned.

9.     int   long

            -
    long    int,   
 .          -
,      -
  typedef.        typedef  -
  int  long,    ,


                           - 9 -










      -
    int,     .
     ,    
    long   int,  -
          
 -a.

10.   

      lint      -
,        .   
,            
          
  .      -
      -h.   ,   *p++
 *          .     
   lint       "null  effect"  ("
").   

    unsigned x ;
    if (x<0) ...

  ,      
  .   , 

    if (x>0) ...

 

    if (x!=0)

       .       
    lint:  "degenerate unsigned comparison"
("        unsigned").    
 

    if (1!=0)...

  lint  "constant in  conditional  con-
text"  ("   "),  -
 1  0   .

      lint   ,  -
        .  , 
-     -
,        -
,      .   -
, 

            if (x & 077 ==0) ...
    
            x<<2 + 40



                           - 10 -










   ,  .    -
        
 ,   lint       
.

     ,       -h    lint
  ,    
 ,           
  .       -
, ,          
       , -
    .

11.     

         ,  -
       .     
 -    .

          (,
=+, =-, ...)   , 

    a=-i;

    

            a =- 1;
     
            a = -1;

         ,  
        -
.  ,        -
 (+=, -=  ..),    -
,    .    -
      lint  -
    .

             .   
    

    int x 1;

  x  1.       -
 : , 

    int x (-1);

      :

    int x (y) {....

       


                           - 11 -










    x    ,  ,  
   .    ,   
,     ,    
   .       
       
 :

    int x= -1;

    -  -
 .

12.   

             -
   ,    ,  -
     .   ,  
-1420     
"  double", ..      -
        .    Honeywell 6000
       
;    ,      
 .    lint      
       
     .     
,     -p  -h,  
"possible  pointer  alignment  problem"  ("   
 ").

13.      

            -
              -
.  ,   ( -1420),    
     ,  -
, ,    .      
      -
  .   ,    
   ,    -
 ,          .
      , 
 , ,      
    .

           
  ,     -
           
(   ) .  -
        
      ,     
.   ,      -
            
-     ,   


                           - 12 -










   .

       lint      ,  
   .  , 

    a[i]=b[i++] ;

  

    warning: i evaluation order undefined
    (:    i).


14.  

      lint         
.         
-[4,5]      
        IBM-370,  IHoneywell 6000  Interdata
8/32.         -
     ,    -
     .

         ,  -
  ,     -
,  lint   ,  -
           ASCII.   
     ,    ,  
     (, -
,   ..),   ,    
   .    ,  
    ,     
      .

          ""  
      .    
    .   , 
          ,
        
      .
,  ,     
      , -
    .

     -      ,   
    ,    
    lint.

15.  

            -
        UNIX.     
-        


                           - 13 -










   .      -
   ,      
  lint.

         
-       .  ,
     ,          
-       (,
int a;).        
   a    .    
   (    ,  
   !),     
   .      -
      .     lint 
   -c,      
.

          -
      .      
   ,      
    .       -
   ,    -
.        ,
 ,         
.       -p  
          
    ,     "
".

           :
         -8,
        .     ,
         
 (" ")    ,        
  (" ")  -1420.   ,
  ,       
  ,        
 ,        .
lint        ,  -
   ,   -
 .

     ,        -
.   ,        , 
   ,   ,      16-
     32-.    , 
     .    
      ,  -
         -
  .        
       -
.         ,  -
,   


                           - 14 -










    x &= 0177700

      x.     -
   -1420,      
  .        -
 :

    x &= 077;

       -
.

           
 -1420       .
      ,   -
       .   -
     -1420,         
 .   ""    
     PDP-11,  -
         .
         ,  
   ,     
.    ,  lint  .

          , 
      , 
     .       
       ,   
  ,      
        .   
          
      -
     .   
  ,       
,     -
      , 
     .      ,
 lint      -
          -  
 .

16.    

      ,      lint.
,       "-
"  ,      
  ..     ,   ,   
,  lint,     "  ",
        -
 .   ,     
      lint,      
.



                           - 15 -










     ,     ,    
.       ,  , ,  
           
          
.       ,    
 ,     -
  .

        ,   ,    
,       lint.  
     :  -
     ,    ,
    .     ,    lint
    ;   
         
,        lint    
.

            -
:  -      -
,   lint   ,     
  lint     /* NOTREACHED */, -
    .   , 
         
,     

    /* NOSTRICT */

    lint     
(    )  .   -v  
      

    /* ARGUSED */

            
     

    /* VARARGS */

    .     
        ,
   .    
     VARARGS,    ,
  ,       ;
,

    /* VARARGS2 */

        .   ,


    /* LINTLIBRARY */



                           - 16 -










   ,  ,      
     .    
 .

17.    

      lint     -
,    -ly,      -
   .       -
        ,    ()
   .      -
 

    /* LINTLIBRARY */

      .  -
     :  
  ,  -     
      ,      
 .      -
       VARARGS 
ARGUSED.

       lint    
 ,     .   
  ,   ,   -
  ,       ,  -
  .   lint   
      ,     
  ,     -
    (-!).

        lint     -
     ,  -
 ,      
   .     -p   ,
             
/,  ,    ,   -
   .        
    -n.

18.    ..

        lint   
  ,      
    ,      ,
      ,  
  ,         
.   (,    ,  lint -
       , -
  ).




                           - 17 -










           lint   
      .  ,  -
    ,   
        
.  ,        -
    typedef;  
 ,          -
  -   .

      lint       -.
      -
   ,     
     ,   -
 ,    -
 ,     ,  -
      ..

      ,   lint,   -
  .    , 
        
    .     
    .

       ,   , 
           .
           
        ,    lint
    ,   
.     lint      -
,        ,
  ,   .    -
 ,    "",      lint  
    "  ".  , -
        
  ,     -
    ,       
  lint      -
.

.     lint

         lint   :

    lint [-]  ... -...


      :

h      

p      




                           - 18 -










v         

u          -
       

b         break

x         -
      

a            long
       int  

c         

n       

s     ,   h (  ).



1.   B.W.Kernighan  and  D.M.Ritchie,  The   C   Programming
     Language,  Prentice-Hall,  Englewood Cliffs, New Jersey
     (1978).

2.   S.C.Johnson, "Yacc -  Yet  Another  Compile-Compiler.",
     Comp.Sci.Tech.Rep.,  No.  32, Bell Laboratiries, Murray
     Hill, New Jersey (July 1975).

3.   M.E.Lesk,  "Lex  -  a  Lexical   Analyzer   Generator",
     Comp.Sci.Tech.R.,  No  39,  Bell Laboratories, Murray
     Hill, New Jersey (October 1975)

4.   S.C.Johnson and D.M.Ritchie, "UNIX Time-Sharing System:
     Portability   of   C  Programs  and  the  Unix  System,
     "Bell.Sys.Tech.J.57(6) pp.2071-2043(1975).

5.   S.C.Johnson, "A Portable  Compiler:  Theory  and  Prac-
     tice", Proc. 5th ACM Symp. on Principles of Programming
     Languages, (January 1978).















                           - 19 -










                         



     .........................................    2

     ..........................................    3

1.    ...................................    3

2.    ...............................    4

3.      .............    4

4.         -
     ............................................    5

5.    ..................................    6

6.    ..................................    7

7.    ...................................    8

8.   ,  . .    9

9.     int   long ....    9

10.   ..............................   10

11.     ............................   11

12.   ...........................   12

13.      .....   12

14.  .......................................   13

15.  .....................................   13

16.    ......................   15

17.    ........................   17

18.   .. .....................................   17

    .     lint ..   18

     ........................................   19







                           - 20 -




Last-modified: Mon, 29 Jun 1998 14:03:12 GMT
: