473,386 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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

Oct 12 '05 #1
5 1998
In article <11**********************@g14g2000cwa.googlegroups .com>,
Pe*******@gmail.com <Pe*******@gmail.com> wrote:
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?


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.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Oct 12 '05 #2
Greg Comeau wrote:
In article <11**********************@g14g2000cwa.googlegroups .com>,
Pe*******@gmail.com <Pe*******@gmail.com> wrote:
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?


The point of using templates is to not do that, since,
that's also difficult, generally speaking.


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

Oct 12 '05 #3
mlimber wrote:
Errors associated with templates
are notoriously verbose and often cryptic (STLFilt not withstanding),
and they make me wish [that] I could have the compiler
emit the code generated from templates
so [that] 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.


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

http://www.netwood.net/~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.
Oct 12 '05 #4
In article <11**********************@g44g2000cwa.googlegroups .com>,
mlimber <ml*****@gmail.com> wrote:
Greg Comeau wrote:
In article <11**********************@g14g2000cwa.googlegroups .com>,
Pe*******@gmail.com <Pe*******@gmail.com> wrote:
>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?


The point of using templates is to not do that, since,
that's also difficult, generally speaking.


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.


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.comeaucomputing.com/tryitout
World Class Compilers: Breathtaking C++, Amazing C99, Fabulous C90.
Comeau C/C++ with Dinkumware's Libraries... Have you tried it?
Oct 12 '05 #5
E. Robert Tisdale wrote:
mlimber wrote:
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.
Take a look at
The C++ Scalar, Vector, Matrix and Tensor class Library

http://www.netwood.net/~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.


Thanks! That might come in handy.

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.


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

Oct 12 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Dhruv | last post by:
I was wondering if anyone could compile this code for me on VC. The problem that I've run into is that VC++6 does not support templates fully, and so, I cannot get this to compile, which relies...
6
by: Ben Ingram | last post by:
Hi all, I am writing a template matrix class in which the template parameters are the number of rows and number of columns. There are a number of reasons why this is an appropriate tradeoff for...
25
by: JKop | last post by:
Using MSWindows as an example: On MSWindows, there's a thing called the System Registry, which is a really big database that holds all the settings of the OS. There's API's for working with the...
4
by: ro86 | last post by:
Hello everyone! I am a newbie to C++ (~1 Week experience) and I have a few months of experience with object-oriented languages (Objective-C). I am currently working just for fun on a particle...
7
by: Samee Zahur | last post by:
Hello, The other day I was rather shocked to find that I couldn't find a good use for runtime polymorphism! Let me explain this a bit further before you get shocked. Any function that I could...
8
by: Victor Lamberty | last post by:
Greetings C coders I am new to the world of C and have been trying to compile this program. I got the result that I wanted but outputed it in a strange way it put it before the prompt is there a...
3
by: Wayne Allen | last post by:
I am receiving a compile error when attempting to include Directshow in a managed C++ program using Visual C++ 2005 Express Edition Version 8. The ..NET framework is version 2.0.50727. To...
3
by: Dmitry Prokoptsev | last post by:
Hello, I need to write a class for exceptions which can be thrown, caught, stored and thrown once again. I have written the following code: --- begin --- #include <string> class Exception...
16
by: desktop | last post by:
I have read that using templates makes types know at compile time and using inheritance the types are first decided at runtime. The use of pointers and casts also indicates that the types will...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.