473,804 Members | 4,795 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2018
In article <11************ **********@g14g 2000cwa.googleg roups.com>,
Pe*******@gmail .com <Pe*******@gmai l.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************ **********@g14g 2000cwa.googleg roups.com>,
Pe*******@gmail .com <Pe*******@gmai l.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************ **********@g44g 2000cwa.googleg roups.com>,
mlimber <ml*****@gmail. com> wrote:
Greg Comeau wrote:
In article <11************ **********@g14g 2000cwa.googleg roups.com>,
Pe*******@gmail .com <Pe*******@gmai l.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
1751
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 heavily on templates. So, if someone can compile the explicit specialication for me with VC++7, and then I could try to use it in VC++6 (probably), if object files are interconvertible, as in I can use object files of VC++7 on VC++6, then? ...
6
3336
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 my particular application. One of the advantages is that the _compiler_ can force inner matrix dimensions used in multiplication to agree. A _complie-time_ error will be triggered if you write A * B and the number of coluns in A does not equal the...
25
3009
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 registry. The two I will be concerned with are: RegOpenKeyEx RegCloseKey Now, here's some code:
4
4803
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 system. All the particles are controlled by a "server". The server performs all kinds of operations on them (updating, drawing etc.). The particles (my "clients") on the other hand need to retrieve once a while some information from their server...
7
5394
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 previously write like this: void func1(Base& obj) { //... obj.virmeth(); //Call virtual method //...
8
2058
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 reason in this code. Or is that just a trait of the KDE Konsole. /*#I hope that this is a C program*/ /*#define hello-computer the output is hello-computer*/ #include <stdio.h>
3
6244
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 recreate the error, do the following steps in Visual C++ 2005 Express Edition: 1. Create a new Windows Forms Application called "Test". 2. In Form1.h, after the #pragma once declaration, add the line "#include <dshow.h>". 3. Add the Platform SDK and...
3
4595
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 { public:
16
5435
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 first be know at runtime. But is there some strict definitions that defines runtime code and compile time code that can be used in general?
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10577
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10077
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9150
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6853
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3820
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2991
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.