4

Possible Duplicate:
How do you count the lines of code in a Visual Studio solution?

I am looking for software or means to count lines of code in a VC6.0: c++ project: 1500 files: cpp, h,

My hunch is there are 2 to 5 million lines of code in this project. I need a means to verify this per file.

thx

Community
  • 1
  • 1
jdl
  • 6,151
  • 19
  • 83
  • 132
  • lines of code is a very poor metric, especially in languages like C++. It is possible to write code that is hundreds of lines long or just a handful, and yet be identical to the compiler. Even more significantly, it is frequently the case that a poor developer will write large amounts of code that could be written as in much fewer lines by a better developer. – Spudley Oct 03 '11 at 11:52
  • 1
    [CLOC](http://cloc.sourceforge.net) – Dialecticus Oct 02 '11 at 21:26

1 Answers1

4

If your code is on a Unix machine with access to the find and wc commands (or you have an installation of Cygwin on your Windows machine), you can use the following shell command:

find . -name \*.cpp -or -name \*.hpp -exec cat {} \; | wc -l

Adjust the wildcards to pick the files that you'd like to scan (the above example picks anything with the .cpp or .hpp extension). There are may be other ways using Visual Studio to do this.

If you absolutely must use a Visual Studio-based solution, look at this Stackoverflow question:

How do you count the lines of code in a Visual Studio solution?

Community
  • 1
  • 1
James Thompson
  • 46,512
  • 18
  • 65
  • 82