NAME

kloc - generate statistics for C/C++ code

SYNOPSIS

kloc [file...]

DESCRIPTION

kloc reads C++ source code, and outputs the following statistics concerning it:

Number of lines:
The total number of lines read.
Lines of code:
The number of lines containing at least one uncommented token.
Preprocessor statements:
The number of preprocessor statements. (A preprocessor statement is a line in which the first non-space character is a '#' character.)
Statements:
The total number of C++ statements (including preprocessor statements).
Lines of comments:
The number of lines which contain a comment of some sort.
Functions:
The number of function definitions.
Lines in functions:
Only if at least one function definition is present, the number of lines containing at least one uncommented token in all of the functions found.
Average lines per function:
Only if at least one function defintion is present, the number of code lines in all of the functions, divided by the number of functions.

OPERANDS

The following operands are supported:

file
A pathname of a file to read. If no file operands are specified, the standard input shall be used.

EXIT STATUS

0 no error.
2 One of the input files could not be opened.
3 Hardware error on standard out.

BUGS

Doesn't truly process pre-processor statements (except for counting them); in particular, conditional compilation is ignored, so both the true and the false branches are counted.

The "parser" is extremely crude, and can easily be fooled.

The number of statements as just a crude approximation, just a count of the number of ';' tokens in the code.