Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

C Programming within UNIX

- UNIX written in C or C++, so basic C compiler usually built in


- not a complete IDE like Borland, but functional and clean
(p. 339)

steps:
1. create source code with text editor (vi, pico)
- best to use the suffix .c to indicate that it is a C program
- then compiler looks for this kind of program

2. to compile, cc programname.c

- get error messages if they exist


go back to editor and correct source and recompile
- no output if compiles properly
and the executable file a.out is created

3. to run, a.out this is the name of the file created by the


compiler
- loads and runs the program

- to specify the name of the output file from the compiler

cc programname.c -o new_file_name
e.g.
cc addition.c -o add

UNIX can let you compile modules separately and then load as one
program
- lets you debug and reuse modules

cc -c addition.c (produces addition.o)


cc -c divide.c (gives divide.o)
- then you link them together into one executable

cc addition.o divide.o main

UNIX gives you tools to maintain your modules


- lets you know which have to be recompiled if any
dependencies are changed

make [-f makefile]

- keeps a list of things which have changed and need to be redone

- need to create a makefile with all the interdependencies that


exist between files

targetList:dependencyList
commandList

- build up a tree of interdependencies

- to force the make process, can update the last modified times to the
present with

touch -c {fileName}

Source Code Control System: SCCS

- UNIX scheme to administer large projects with various


authors and versions
- lets you “sign-out” code to modify and tracks what is
happening and when
- use the admin utility to maintain the SCCS information
- can provide a history of changes
- supports version control, locking releases

You might also like