Locness Rules of Counting Unfortunately, no standards organizations (ANSI, ISO, etc) has come up with a policy on how to count source code in any language. So I came up with my own rules which is quite open for debate. C++ is a vast language so I haven't included every possible way of counting. Therefore, the program as well as this section here could (and probably would) change in the future. So here goes.... Classes
public c { class d // 1 LOC { }; };
{ }
Functions
woid funct1() // 1 LOC { int a; }
{ } Variables
short b, c, d; // 3 elements
int b = 1, c = 2; // 2 variables, 2 initialization statements Statements
#define __BYE__ \ GOODBYE // 1 LOC, continued from previous line
{ case 1: // LOC case 2: // LOC ...
default: // LOC ... }
...; else // not counted separately ...;
if (b == 1) // 1 LOC ... else if (b == 2) // 1 LOC for the if ... else // not counted separately ...
... while (true); // not counted separately
while(true) // 1 LOC ...
for(a=0;a<10;a++) // 1 LOC
...
try // 1 LOC { ... } catch(int a) // not counted separately { ... } catch(...) // 1 LOC { ... }
|