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 5 1461
* 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?
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.
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? 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) 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) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Oplec |
last post by:
Hi,
I'm learning C++ as a hobby using The C++ Programming Language : Special
Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that
deal with templates. Exercise 13.9 asks for me...
|
by: Alibek |
last post by:
Hello !
I have here template class with
static members. and I put definition of the static member in the same
..h file where the class was declared.
however, we are getting very stange...
|
by: jack |
last post by:
Hi there,
I have a function F(x, y, z)
and I want to calculate f(a) + f(b), where f(x) = F(x, x, z0)
z0 is fixed.
Suppose somebody wrote a routine called "Compute" which simply
computes f(a)...
|
by: Tony Johansson |
last post by:
Hello Experts!
What does this mean actually.
If you have a template with a type and non-type template argument, say, like
this
template<typename T, int a>
class Array {. . .};
then A<int,...
|
by: Micha |
last post by:
Hello there,
I think I've run into some classic c++ pitfall and maybe some of
you guys can help me out.
For my project I will need to use matrices and vectors and so I
decided to implement them...
|
by: shablool |
last post by:
Hi all,
Could someone please explain what is wrong with this code (the compiler
complains about "'int_type' is not a member of 'B'"):
struct B;
template <typename DerivedT>
struct A
{
|
by: Atlas |
last post by:
Hi,
I implemented a template as:
template <int L, int M, int T>
class Quantity
{
.....
public:
friend Quantity operator*(const Quantity& q1,const Quantity& q2);
.....
};
|
by: mlimber |
last post by:
This is a repost (with slight modifications) from
comp.lang.c++.moderated in an effort to get some response.
I am using Loki's Factory as presented in _Modern C++ Design_ for
message passing in...
|
by: H9XLrv5oXVNvHiUI |
last post by:
Hi, I have a question about injecting friend functions within template
classes. My question is specific to gcc (version 3.4.5) used in
combination with mingw because this code (or at least code...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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: 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,...
|
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...
|
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...
| |