any tool for template debugging ?

T

toton

Hi,
Is there any tool for template debugging, during compilation process
? Just like gdb or visual studio debugger do it during program
execution, a step by step debug for the program,
I am looking for something which will do the process during
compilation and show what is getting substituted for which call.
Otherwise sometimes, compilation fails saying some value_type can't be
substituted by value_type& and etc inside a template call, but it never
reports who calls it, and in turn all of the steps the compiler follow
to substitute it.
Thus I want to get through the template substitution states that the
compiler uses , and the type parameters that it substitutes, and the
exact specialization that it makes, which will give a justification of
the compiler error that it generates, rather than at run time

thanks
abir
 
K

kwikius

toton said:
Hi,
Is there any tool for template debugging, during compilation process
? Just like gdb or visual studio debugger do it during program
execution, a step by step debug for the program,
I am looking for something which will do the process during
compilation and show what is getting substituted for which call.
Otherwise sometimes, compilation fails saying some value_type can't be
substituted by value_type& and etc inside a template call, but it never
reports who calls it, and in turn all of the steps the compiler follow
to substitute it.
Thus I want to get through the template substitution states that the
compiler uses , and the type parameters that it substitutes, and the
exact specialization that it makes, which will give a justification of
the compiler error that it generates, rather than at run time

This is a major problem in C++. The 'Big Idea' to attempt to do
something about the problem is Concepts:

http://www.generic-programming.org/languages/conceptcpp/

The idea is that instead of using 'raw' template parameters for a
function or class template, that you specify the allowable types for
the template parameter by only allowing types that conform to a
Concept. When you invoke the function on a particular type the
compiler checks whether the type conforms to the Concept and if not
should in theory give you a much more precise error message as to what
the problem is, and point you at the place where the problem is.

There is a downloadable compiler based on gcc which you can use to test
out how this scheme might look:

http://www.generic-programming.org/software/ConceptGCC/

It isnt finished and is far from perfect but is well worth trying out.
There is a good chance Concepts will become part of C++, but currently
the scheme needs lots more user feedback to improve it.

FWIW Here is my ConceptGCC installation for Windows guide:

You need to have Cygwin installed:

http://www.cygwin.com/

Download the ConceptGCC compiler:

http://www.generic-programming.org/software/ConceptGCC/download.php

Assuming cygwin is installed correctly you can unzip the download
using:

'tar -xvjf conceptgcc-VERSION-cygwin.tar.bz2

Move the resulting 'opt' directory to your Cygwin installation. In my
case
C:/Cygwin

So in my case the result is C:/Cygwin/opt

Head for Start>Control Panel.
Head for System>Advanced>Environment Variables.
Find 'Path' environment variable
Add The ConceptGcc bin directory e.g
PREVIOUS_Stuff;C:/Cygwin/opt/conceptgcc-VERSION/bin


Now check it works. Open a command prompt. (If you have Cygwin
correctly
installed you shouldnt need to be in Cygwin shell)

type conceptg++.

If all is working ok you should get:

C:\my_current_dir>conceptg++
conceptg++: no input files

C:\my_current_dir>

You can invoke the compiler from a command prompt in your current
directory by:
// (compile followed by link)

conceptg++ -c test.cpp
conceptg++ -o testprog.exe test.o

Next.. Head for the tutorial:

http://www.generic-programming.org/languages/conceptcpp/tutorial/

regards
Andy Little
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top