How to compile C++ program with templates to pure C or C++ program without templates?

How to compile C++ program with templates to pure C or C++ program without templates?

Post by PengYu.U » Thu, 13 Oct 2005 23:50:23


Hi,

I heard that debug some C++ templates is very difficult. I'm wondering
whether it is possible to compile C++ program with templates to pure C
or C++ program without templates?

Best wishes,
Peng
 
 
 

How to compile C++ program with templates to pure C or C++ program without templates?

Post by comea » Thu, 13 Oct 2005 23:53:41

In article < XXXX@XXXXX.COM >,


The point of using templates is to not do that, since,
that's also difficult, generally speaking.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.yqcomputer.com/
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?

 
 
 

How to compile C++ program with templates to pure C or C++ program without templates?

Post by mlimbe » Fri, 14 Oct 2005 01:30:21


Errors associated with templates are notoriously verbose and often
cryptic (STLFilt not withstanding), and they make me wish I could have
the compiler emit the code generated from templates so I could more
easily see what was wrong. It would be similar to examining the output
of the preprocessor to debug macros. I don't know of any compiler that
does this, however.

Cheers! --M
 
 
 

How to compile C++ program with templates to pure C or C++ program without templates?

Post by E. Robert » Fri, 14 Oct 2005 01:52:07


Take a look at
The C++ Scalar, Vector, Matrix and Tensor class Library

http://www.yqcomputer.com/ ~edwin/svmtl/

The genclass shell script

svmtl/bin/genclass

is a customized version of the original genclass script
written by Doug Lea.
We used this script for generic programming
before Bjarne had a proper implementation of templates.
It can't do all of the things that templates can do
but it does create human readable output that you can debug.

Most compilers have an option (gcc -E for example)
that displays the output from the C preprocessor (cpp)
before it is passed to the C++ compiler proper.
This output includes all of the macro substitutions
and allows you to debug macro definitions.
 
 
 

How to compile C++ program with templates to pure C or C++ program without templates?

Post by comea » Fri, 14 Oct 2005 03:33:19

In article < XXXX@XXXXX.COM >,




Errors associated with other alternative similar things are also
notoriously verbose and often cryptic and don't even have something
such as STLfilt. This does not excuse either though and
I agree more needs to be done.
--
Greg Comeau / Celebrating 20 years of Comeauity!
Comeau C/C++ ONLINE ==> http://www.yqcomputer.com/
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
 
 
 

How to compile C++ program with templates to pure C or C++ program without templates?

Post by mlimbe » Fri, 14 Oct 2005 03:47:22


Thanks! That might come in handy.


Right. Sorry for the ambiguity: I meant that I didn't know of any
compiler that generated code from templates. All the compilers I'm
familiar with can dump the output of the preprocessor.

Cheers! --M