The file that contains the code I'm working on is named "coord.h". My code does not contain a corresponding coord.c or coord.cpp file. Is there a naming convention for C++ headers?
The long whitespace is for readability when I collapse my functions. Visual C++ collapses functions to their header and makes it easy to look at all your functions in a file. For example:
Code:
void functiona(register struct blah *rtmp)
static int functionb()
struct blah * functionc(register struct obj *otmp, coord xy, bool foo)
If I just put a space between the return type and the function header, I see:
Code:
void functiona(register struct blah *rtmp)
static int functionb()
struct blah * functionc(register struct obj *otmp, coord xy, bool foo)
I've seen others use new lines:
Code:
void
functiona(register struct blah *rtmp)
static int
functionb()
struct blah *
functionc(register struct obj *otmp, coord xy, bool foo)
Which choice is most readable?
As for matsp's suggestion that I rename all my code files .CPP, I just tried it and received many compiler errors, some involving flex code files, others involving reserved C++ keywords (class), some having to do with the project's implementation of "boolean", and yet others about being unable to convert from void* to char*.
I'm trying to transition this code from C to C++. I was hoping that I could take little steps, one at a time, rather than having to make drastic changes to the entire code all at once. I've been making sure that I can compile and run this program after each significant change I make so I know that nothing I've done breaks everything. While my goal would be to eventually rename all 100+ .c files to .cpp and make sure that everything that's being used conforms to C++ standards and OOD, I am not arrogant enough to think that a beginning programmer could possibly understand everything that's going on in the 150,000+ lines of code in this project. I do not want to discount the knowledge, experience, and efforts of dozens of other programmers on multiple platforms who have written a compilable and working program, regardless of how many bugs may exist in it. In my book, compilable and working trumps elegant and irreparable. Some things I do may introduce other bugs, but my goal is to make it easy for other beginners to be able to read and understand what's going on.