• Linux
  • August 2019
    M T W T F S S
    « Jul    
  • Meta

  • Follow me on Twitter

  • Advertisements

FnLoC – LOC Counter

FnLoC (Function Lines of Code) is a program that runs from the command line or terminal and counts logical lines of code in C and C++ source code files disregarding comments and blank lines. It counts functions and lists them by name, including return type and parameters, with the count of lines of code contained in the function.

The program was written with small coding projects in mind such as school programming assignments. In fact, I originally wrote the program for a software engineering class in my Computer Science coursework.

The program assumes that the code is written according to modern C coding standards as illustrated in The C Programming Language, 2nd edition by Brian W. Kernighan & Dennis M. Ritchie with some style borrowed from Linux Kernel Coding Style by Linus Torvalds plus a bit of my own style.

But there are only a couple hard and fast rules that the program expects. Functions are expected to have their opening brace as the first character on the line following the function header and data structures should have their opening brace at the end of the first line.

There is a reasonable expectation of well-formatted code but outside of the previous caveats it’s not absolutely necessary. The documentation (README) has more detailed information about the program’s behavior and limitations.

The program was compiled using gcc on Linux Mint 18.3 and MinGW gcc on Windows 7. The Linux version should work on any Linux distribution and the Windows executable should work on any Windows version. I don’t see any reason wouldn’t work on a Mac but you’d have to compile the source code.

FnLoC is licensed under the GNU General Public License, version 2. Of course, the software is provided “as is” and there are no expressed or implied warranties. It’s all in the documentation.

The program (to include source code) can be downloaded from my GitHub repository. The files in my Dropbox/Public folder are no longer maintained and any program-related files in my Dropbox are out of date.

%d bloggers like this: