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

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



H.S. wrote:
> Hello,
> 
> This is related to templates in C++ and debugging tools we have in Linux
> (I use gdb, is there any other comparable open source tool?).
> 
> 
> What do C++ programmers here think about the usefulness of using
> templates in C++ while keeping in mind how it would work with debugging
> that program using gdb.
> 
> I recall that a few years ago (a few version of gdb and gcc ago) I was
> having trouble debugging an algorithm I implemented in C++ using
> templates. I do not recall the exact problems but after a few online
> searches it appeared that the easiest way was to not to use templates
> (one problem was that I has having difficulty to examine template
> variables). IIRC, gdb was not very friendly while debugging C++ code
> with templates.
> 
> 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.
IIRC things are slightly better than several ago. I had been debugging several C++
problems with templates without significant problems during last years. However, some
things are not debuggable by design - template variables are compile-time things, I doubt
where can gdb find values of even non-type variables.

-- 
Eugene V. Lyubimkin aka JackYF, JID: jackyf.devel(maildog)gmail.com
Ukrainian C++ developer, Debian Maintainer, APT contributor

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: