[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [OT] C++ templates and debugging (limitations) in Linux



On Thu January 29 2009 10:47:27 H.S. wrote:
> Can C++ programmers here share their recent experience in this regard? I
> have a program for an engineering problem of around 5000 lines and I
> need to change some of the data variable from one type to another.
> Currently I am of the mind to just change the variable type. Would it be
> worthwhile instead to use templates in this situation so that I can then
> maintain only one copy for different data types? I am debugging the
> source code using gdb and I am not sure if it will become much more
> tedious to debug if I use templates. Comments and feedback are welcome.

Maintaining one copy instead of two is (almost) always a good idea,
and one of the reasons why templates are so valuable.

Start with a working program.  Make a small change.  Fix compilation
errors.  Test it.  Fix any problems.  Commit to VCS.  Repeat.

Occasional misbehavior is usually resolved with the assistance of
"std::cerr << foo;" or a more sophisticated variant.  About the only
time I use gdb is to find a clue if a bug causes a segfault.

In your case it may be possible to incrementally convert the code
for the original datatype to templated code, and then once that is
done add the second datatype.

There are more appropriate places than debian-user for C++ questions.

--Mike Bird


Reply to: