M
Martin Wells
When I have errors in a program, whether they be compiler errors,
linker errors, or if the program crashes when running, I have a list
of things I check for initially.
If I get an error for something undeclared, the first thing I do is go
through my header files and check that the inclusion-guard macro is
specific to that header file. For instance, if the header file is
called "data.h", I make sure the inclusion guard is "H__DATA" and not
something like "H__GUI". The reason I have to check for this is that I
commonly copy-paste inclusion guards from one header file to another.
The program I'm currently developing was crashing when running, the
error being an invalid memory access. I went through the offending
function line-by-line and it wasn't long before I spotted the error. I
have a strong habit of writing the following:
char *p = data;
char const *const pover = data + sizeof data;
This habit was so strong that it led me to write:
unsigned *p = data;
unsigned const *const pover = data + sizeof data;
....when of course I should have written: + sizeof data/sizeof*data
So next thing I did was do a find for "sizeof" in every one of the
files to make sure I hadn't made the same error elsewhere.
What kind of things do you all check for initially when presented with
a certain kind of error? One thing I find helps greatly is turning off
implicit int and also implicit function declarations via the compiler
options.
Martin
linker errors, or if the program crashes when running, I have a list
of things I check for initially.
If I get an error for something undeclared, the first thing I do is go
through my header files and check that the inclusion-guard macro is
specific to that header file. For instance, if the header file is
called "data.h", I make sure the inclusion guard is "H__DATA" and not
something like "H__GUI". The reason I have to check for this is that I
commonly copy-paste inclusion guards from one header file to another.
The program I'm currently developing was crashing when running, the
error being an invalid memory access. I went through the offending
function line-by-line and it wasn't long before I spotted the error. I
have a strong habit of writing the following:
char *p = data;
char const *const pover = data + sizeof data;
This habit was so strong that it led me to write:
unsigned *p = data;
unsigned const *const pover = data + sizeof data;
....when of course I should have written: + sizeof data/sizeof*data
So next thing I did was do a find for "sizeof" in every one of the
files to make sure I hadn't made the same error elsewhere.
What kind of things do you all check for initially when presented with
a certain kind of error? One thing I find helps greatly is turning off
implicit int and also implicit function declarations via the compiler
options.
Martin