what to do with template classes in template unsupported compiler ?

S

Shlomi

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
 
A

Alf P. Steinbach

* (e-mail address removed) (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.
 
G

Greg Comeau

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.
 
S

Shlomi

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)
 
S

Shlomi

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)
 

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

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top