this post was submitted on 31 Jan 2025
8 points (90.0% liked)

C++

1838 readers
4 users here now

The center for all discussion and news regarding C++.

Rules

founded 2 years ago
MODERATORS
 

I've tried a few tools like cloc to count the lines of code within my cpp project.

However, they are pretty surface level and just count the lines.

Is there anything that is able to show how many lines are for classe, imports, simple aliases, typedefs, and more detailed info like that.

My codebase is using C++ 20 modules and a lot of it is just imports and namespace aliases, so just counting the lines is pretty inaccurate. A lot of the files are simply just 10-20 lines at the header for imports, etc, and then just a small child class with constructors.

Which is to say that it's >50% "filler" in a lot of files.

If anyone knows any tools for this, ideally FOSS, please let me know. Thanks!

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 2 points 20 hours ago (1 children)

I didn't even think about how context dependent C++ is until you mentioned that. That's a really good point

[โ€“] [email protected] 1 points 44 minutes ago

Yeah basically C++ is fun (or "fun") in that in order to try and get what code does or what it means you have pretty much no other alternative than trying to compile it.

There are a number of terms that have only one meaning and can appear in only one "semantic place", such as namespace, return and... I think that's it? Maybe (maaaaybe) .*. So it's little enough that doesn't give you that much good information if you try and hand-parse them out from the code you have.