The difference between C89 and C99
I have a project that I have written in C99. It uses variadic macros, new-style function definitions, and variable declarations can occur below statements. These things are outside the scope of the original C89 draft, so they're technically C99. However, a guy working with me has stated that he'd like to transition it to C89 for greater compiler compatibility.
I sometimes get confused about exactly what is considered C89 and what is not. New-style function definitions are ubiquitous, but do people consider that they're writing in C99 if they use them?
I'd like my project to be as portable as possible. Realistically, how many compilers that are worth using are going to fail to compile my code?
Richard
What about struct initialization?
What about struct initialization? You could convert:
Code:
struct mystruct s = { 1, 2, 3 };
into :
Code:
struct mystruct;
mystruct.one = 1;
mystruct.two = 2;
mystruct.three = 3;
but then you can't declare any struct members const (which I have done as an error-checking measure).
Variables names and comments
I hear so many conflicting things about good programming practice.
Sure, you should label variables something descriptive, but what constitutes a good description? For example, in my code I iterate through command line parameters using:
Code:
int arg;
for (arg=0;arg<argc; arg++)
...
Now, what should I call it? i_argument, consoleargument, from1toargc, commandlineoptionscounter?
And as to comments, I reckon the code should be easily readable. The best way to understand the code is to read it and figure out what it does. Good function names and variable names is a part of that.
Richard