By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,408 Members | 945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,408 IT Pros & Developers. It's quick & easy.

what to do with template classes in template unsupported compiler ?

P: n/a
Hi !

I've wrote quite a big code which bases on a considerable large amount
of template classes. (uses many different kinds of each template
class).

Now, without prior knowledge of mine, it turns out that this code
should
be compiled with compiler which doesn't support templates ! (OUCH!)

after my face got back to its normal color, we've started of thinking
what are our options:
1. rewrite the template classes such that there'll be a unique class
to each of them (think about all the relations between the different
kinds - it's like a cartesian product of each function which recieve
other template class argument...) one big head-ache.
2. write a parser which will do the work. (and hope)
3. search for a tool which does that or something similar.
4. maybe use a C++ to C translator.
5. write a template supported compiler for the specific platform
(mmm.. guess not)
6. ask in comp.lang.c++ google groups for ideas... (anyone?)

help would be very appreciated.

Thanks in advance,
Shlomi
Jul 22 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
* sh*****@il.ibm.com (Shlomi) schriebt:

I've wrote quite a big code which bases on a considerable large amount
of template classes. (uses many different kinds of each template
class).

Now, without prior knowledge of mine, it turns out that this code
should
be compiled with compiler which doesn't support templates ! (OUCH!)

after my face got back to its normal color, we've started of thinking
what are our options:
1. rewrite the template classes such that there'll be a unique class
to each of them (think about all the relations between the different
kinds - it's like a cartesian product of each function which recieve
other template class argument...) one big head-ache.
2. write a parser which will do the work. (and hope)
3. search for a tool which does that or something similar.
4. maybe use a C++ to C translator.
5. write a template supported compiler for the specific platform
(mmm.. guess not)
6. ask in comp.lang.c++ google groups for ideas... (anyone?)

help would be very appreciated.


This is sort of off-topic, but it seems most probable that you have
been intentionally screwed by management. In that case there is nothing
you can do; if by heroic effort you manage to make the code compatible with
current requirements new unsurmountable requirements will pop up. If, OTOH.,
although very unlikely, that is not the case: the cost of a compiler that does
support templates is negligible, namely zero for most platforms.

--
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Jul 22 '05 #2

P: n/a
Shlomi wrote:
4. maybe use a C++ to C translator.


Try Comeau's C++ compiler. It generates C as its output. (And it works
really well.)
http://www.comeaucomputing.com/
Jacques.

Jul 22 '05 #3

P: n/a
In article <Qb******************@news02.tsnz.net>,
Jacques Labuschagne <ja*****@clawshrimp.com> wrote:
Shlomi wrote:
4. maybe use a C++ to C translator.


Try Comeau's C++ compiler. It generates C as its output. (And it works
really well.)
http://www.comeaucomputing.com/


We usually offer full end user products, not partial solutions
(usually because they don't help).

The OP mentioned: "Now, without prior knowledge of mine, it turns
out that this code should be compiled with compiler which doesn't
support templates ! (OUCH!)" But do you mean the compiler is
a C compiler? A C++ compiler which does not support templates?
A full C++ compiler, but you are by corp policy not allowed to
use template? Etc. Please elaborate so the group can have
have a better understanding of your need and concerns and
advise from there.
--
Greg Comeau / Comeau C++ 4.3.3, for C++03 core language support
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?
Jul 22 '05 #4

P: n/a
co****@panix.com (Greg Comeau) wrote in message news:<c8**********@panix1.panix.com>...
In article <Qb******************@news02.tsnz.net>,
Jacques Labuschagne <ja*****@clawshrimp.com> wrote:
Shlomi wrote:
4. maybe use a C++ to C translator.


Try Comeau's C++ compiler. It generates C as its output. (And it works
really well.)
http://www.comeaucomputing.com/


We usually offer full end user products, not partial solutions
(usually because they don't help).

The OP mentioned: "Now, without prior knowledge of mine, it turns
out that this code should be compiled with compiler which doesn't
support templates ! (OUCH!)" But do you mean the compiler is
a C compiler? A C++ compiler which does not support templates?
A full C++ compiler, but you are by corp policy not allowed to
use template? Etc. Please elaborate so the group can have
have a better understanding of your need and concerns and
advise from there.


The code is aimed for embedded processors platforms.
The compilers are C++ but there are restrictions:
1. no exceptions.
2. no templates.
because some of the platform's compilers doesn't support them.

I'm trying now to "instantiate" the different kinds of classes myself,
but it's not easy.
so now I have other problem:
I had a template:
template <int t>
class T {
public:
// ...
template <int s>
T& f(const T<s>&) {T.g();}
void g();
// ...
}

The following classes A and B were
templated from T and now I try to manually instantiate them:

the header:

class B; //forward decleration

class A {
public:
// ...
A& f(const B&) {B.g();}
void g();
// ...
}

class B {
public:
// ...
B& f(const A&) (A.g();}
void g() {};
// ...
}

this wont compile (can't use class B functions in A's decleration,
becuase B haven't been declared yet)
so I leave only the function member f decleration in A's header
and write f body in its cpp file.
but it wont let me *inline* it , why? (the inline is very important for optimizing)

any solution ?

(thanks in advance)
Jul 22 '05 #5

P: n/a
sh*****@il.ibm.com (Shlomi) wrote in message news:<c7**************************@posting.google. com>...
co****@panix.com (Greg Comeau) wrote in message news:<c8**********@panix1.panix.com>...
In article <Qb******************@news02.tsnz.net>,
Jacques Labuschagne <ja*****@clawshrimp.com> wrote:
Shlomi wrote:
> 4. maybe use a C++ to C translator.

Try Comeau's C++ compiler. It generates C as its output. (And it works
really well.)
http://www.comeaucomputing.com/


We usually offer full end user products, not partial solutions
(usually because they don't help).

The OP mentioned: "Now, without prior knowledge of mine, it turns
out that this code should be compiled with compiler which doesn't
support templates ! (OUCH!)" But do you mean the compiler is
a C compiler? A C++ compiler which does not support templates?
A full C++ compiler, but you are by corp policy not allowed to
use template? Etc. Please elaborate so the group can have
have a better understanding of your need and concerns and
advise from there.


The code is aimed for embedded processors platforms.
The compilers are C++ but there are restrictions:
1. no exceptions.
2. no templates.
because some of the platform's compilers doesn't support them.

I'm trying now to "instantiate" the different kinds of classes myself,
but it's not easy.
so now I have other problem:
I had a template:
template <int t>
class T {
public:
// ...
template <int s>
T& f(const T<s>&) {T.g();}
void g();
// ...
}

The following classes A and B were
templated from T and now I try to manually instantiate them:

the header:

class B; //forward decleration

class A {
public:
// ...
A& f(const B&) {B.g();}
void g();
// ...
}

class B {
public:
// ...
B& f(const A&) (A.g();}
void g() {};
// ...
}

this wont compile (can't use class B functions in A's decleration,
becuase B haven't been declared yet)
so I leave only the function member f decleration in A's header
and write f body in its cpp file.
but it wont let me *inline* it , why? (the inline is very important for optimizing)

any solution ?

(thanks in advance)

I solved it... thanks anyway
(the solution is not using a cpp file and put the body of the function
in the end of the header)
Jul 22 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.