PDA

View Full Version : Checking lines of code



DavidP
04-09-2008, 05:35 PM
Is there a way in Code::Blocks to check how many lines of code are contained in the entire project or workspace that you are working in?

dwks
04-09-2008, 05:37 PM
You could always use the command "wc". I'm not sure if Code::Blocks has anything or not.

It's pretty easy to write your own line counter, but of course, it wouldn't be integrated with Code::Blocks.

DavidP
04-09-2008, 05:39 PM
Oh please.....why would I want to write my own line counter in a matter of minutes which would take up maybe 50 lines of code at most when I could be lazy and have another person do it for me? :rolleyes:

dwks
04-09-2008, 05:41 PM
Very well, try mine. ;) It's called makewc.sh in here: http://dwks.theprogrammingsite.com/myprogs/down/xuni-1.0.0-svn-89.tar.gz

You asked for it. :)

That's assuming you have bash, which you might not.

matsp
04-09-2008, 05:43 PM
gnuwin32 has a "wc" program that lists lines, words and characters per file. Assuming you don't have lots of "spare" .C/.CPP files (etc) laying about in the same directory, and not too many directories in your project, something like:


c:\myprojects\thisproj\>wc --lines src\*.cpp inc\*.h

will give you a list of filenames and the respective number of lines, along with a total for all files.

--
Mats

dwks
04-09-2008, 05:48 PM
My shell script does basically that, except it works for multiple directories and filenames with spaces in them. (Well, the latest version does. That one doesn't.) It also discards .c files when there are corresponding .y files, because that's something I needed.

CornedBee
04-10-2008, 02:05 AM
find -iname "*.{cpp,hpp}" | xargs wc --lines
would also work, as long as you don't overflow the command line.