• Linux
  • December 2018
    M T W T F S S
    « Nov    
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
  • 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.

Downloads:

My FnLoC project on GitHub

fnloc.deb (Debian, Ubuntu, Mint)

fnloc-installation-files.tar.gz (Linux)

FnLoC_install.zip (Windows)

fnloc.tar.gz (FnLoC Source Code)

Advertisements
%d bloggers like this: