Program Development



  1. Languages.
    1. awk
    2. C/C++
      C/C++ Is the most popular language under Unix systems. The kernel is written in C, and all of the operating system hooks are defined in terms of C. The command to compile a C program is cc. C tools include:
      1. cb
        The c beautifier.
        $ cat lotto.c
        #include <time.h>
        main() { int n[51]; int i,j,k,t; long timval;
        (void) time(&timval); srand(timval); for(i=0;i<51;i++) n[i]=0;
        i=6; while(i) { k=rand()%50+1; if(n[k]) continue; n[k]++; i--; }
        for(i=0;i<51;i++) if (n[i]) printf("%02d\t",i); printf("\n"); }
        
        $ cb lotto.c
        #include <time.h>
        main() { 
                int n[51]; 
                int i,j,k,t; 
                long timval;
                (void) time(&timval); 
                srand(timval); 
                for(i=0;i<51;i++) n[i]=0;
                i=6; 
                while(i) { 
                        k=rand()%50+1; 
                        if(n[k]) continue; 
                        n[k]++; 
                        i--; 
                }
                for(i=0;i<51;i++) if (n[i]) printf("%02d\t",i); 
                printf("\n"); 
        }
        
      2. cflow
        cflow generates a flow graph fo the fucntions..
        $ cflow animal.c
        1       main: int(), <animal.c 15>
        2               printf: <>
        3               yes: int(), <animal.c 55>
        4               gensis: int(), <animal.c 28>
        5                       make_node: struct*(), <animal.c 46>
        6                               malloc: <>
        7                               strcpy: <>
        8               endgame: int(), <animal.c 63>
        9                       printf: 2
        10                      yes: 3
        11                      gets: <>
        12                      make_node: 5
        13              guess: int(), <animal.c 33>
        14                      printf: 2
        15                      yes: 3
        16                      endgame: 8
        17                      guess: 13
        
      3. lint
        lint checks for bug or nonportable use of C.
        $ lint animal.c
        animal.c(25): warning: main() returns random value to invocation environment
        animal.c(58): warning: b set but not used in function yes
        malloc value used inconsistently        llib-lc(441)  ::  animal.c(48)
        malloc value declared inconsistently    llib-lc(441)  ::  animal.c(48)
        printf returns value which is always ignored
        strcpy returns value which is always ignored
        gets returns value which is always ignored
        
      4. prof
        $ cc -p lotto.c
        $ a.out
        01      14      18      27      30      33
        cochise : prof
         %time  cumsecs  #call  ms/call  name
         100.0     0.01      7     1.43  _printf
           0.0     0.01      7     0.00  __doprnt
           0.0     0.01      1     0.00  __findbuf
           0.0     0.01     18     0.00  _strlen
           0.0     0.01      1     0.00  _time
           0.0     0.01      1     0.00  _write
        
    3. Fortran
      f77 Fortran 77 compiler
    4. pascal
    5. sh, ksh, csh, bash tcsh
    6. lex and yacc
      lex & yacc used for developing compilers.
    7. java
    8. perl


  2. make
    Make is used to maintain large programs that consists of many source files or several complex steps to create the executable. The general format of a makefile is:
     target: dependencies
            rules
    
    $ cat makefile
    cwall.o : cwall.c
            cc -c -I/local/include cwall.c
    
    cwall: cwall.o
            cc -o cwall cwall.o  $(LOAD_DIR) $(XLIB)
    
    clean:
            rm *.o
    $  make cwall
    `cwall' is up to date.
    $ make clean
    rm *.o
    $ make cwall 
    cc -c -I/local/include cwall.c
    cc -o cwall cwall.o  -L/local/lib -lX11
    
    $cat makefile
    newp: newp.o
            sqla.ld newp newp.o  date/conv.a -L/local/lib -lXm -lXt -lX11
    
    newp.o: newp.c
            ucc -D_NO_PROTO -I/appl/ASQL/ -I/local/include -c newp.c
    
    newp.c: newp.ec
            EPP newp.ec  
    
    clean:
            rm *.[cou]
    
    $ make clean
    rm *.[cou]
    $ make newp
    EPP newp.ec  
    newp.ec:
    ucc -D_NO_PROTO -I/appl/ASQL/ -I/local/include -c newp.c
    cc: Warning: "-E" redefines produce from "object" to "source"
    sqla.ld newp newp.o  date/conv.a -L/local/lib -lXm -lXt -lX11
    unknown option 'q'
    usage: config [-p] [-n] [-f] [-o OBJ] sysname
    loading SQL/A APPLICATION local_only as newp
    Fri Dec  4 08:18:11 CST 1992
    Finished loading SQL/A APPLICATION newp
    Fri Dec  4 08:18:36 CST 1992
    
    $ cat makefile
     .SUFFIXES :
     .SUFFIXES : .s .t .p 
     .s.t :
             tbl $< | eqn | troff -ms   >$*.t
     .s.p :
             tbl $< | eqn | psroff -ms -Pchpclw
     clean:
            rm -f *.t
    $ make clean
    rm -f *.t
    $ make a190.t
    tbl a190.s| eqn | troff -ms   >a190.t
    

© Allan Kochis Last revision 12/27/1999