473,394 Members | 1,828 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,394 software developers and data experts.

template error

Hello,

I am trying to compile some code that includes third party header files
(part of a library). I keep getting an error on the templates they've
defined. An example error follows:

"/usr/local/SensAble/GHOST/v31/include/gstGenericMatrix.h", line 115:
error(1424):
constant "DIMM" is not used in declaring the parameter types of
function template "gstGenericMatrix::mulPointMatrix"
template <class PT1, class PT2, class MAT, int DIMM, int DIMN>

The code excerpt that generates this error is:

template <class PT1, class PT2, class MAT, int DIMM, int DIMN>
inline void mulPointMatrix(PT1 & res,
const PT2 & p,
const MAT & m)
{
for (int i = 0; i < DIMN; ++i)
{
res[i] = 0;
for (int j = 0; j < DIMM; ++j)
{
res[i] += p[j] * m[j][i];
}
}
}

Does anyone know what the problem is? As mentioned, this is a header file
for a third-party library (that I don't have source code for). Apparently,
they built their applications with MIPSpro 7.3. I am using MIPSpro 7.2.1 on
an Octane running Irix 6.5.19f. Is this something that is allowed in MIPSpro
7.3, but not MIPSpro 7.2.1?

Thanks for any help,
Adam
Jul 19 '05 #1
6 1627
On Tue, 19 Aug 2003 12:53:18 -0400, "Adam Coutee" <gt*****@prism.gatech.edu> wrote:
I am trying to compile some code that includes third party header files
(part of a library). I keep getting an error on the templates they've
defined. An example error follows:

"/usr/local/SensAble/GHOST/v31/include/gstGenericMatrix.h", line 115:
error(1424):
constant "DIMM" is not used in declaring the parameter types of
function template "gstGenericMatrix::mulPointMatrix"
template <class PT1, class PT2, class MAT, int DIMM, int DIMN>

The code excerpt that generates this error is:

template <class PT1, class PT2, class MAT, int DIMM, int DIMN>
inline void mulPointMatrix(PT1 & res,
const PT2 & p,
const MAT & m)
{
for (int i = 0; i < DIMN; ++i)
{
res[i] = 0;
for (int j = 0; j < DIMM; ++j)
{
res[i] += p[j] * m[j][i];
}
}
}

Does anyone know what the problem is?


That the compiler requires all template parameters to be used somehow
in the function's signature (because the compiler says so).

One solution could be to introduce dummy arguments, like so:
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
int dummy1 = DIMM,
int dummy2 = DIMN
)
or perhaps
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
int dummy1[DIMM] = 0,
int dummy2[DIMN] = 0
)
Another solution, to use a better compiler.

A third solution, not incompatible with the second, to use a better
library... ;-)

Jul 19 '05 #2

"Alf P. Steinbach" <al***@start.no> wrote in message news:3f****************@News.CIS.DFN.DE...
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
int dummy1 = DIMM,
int dummy2 = DIMN
) I don't think this one will work. If the compiler relies on the function signature
to differentiate the template specializations, then it still fails.
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
int dummy1[DIMM] = 0,
int dummy2[DIMN] = 0
)


I don't think this will work either, the arrays are converted to int* to form the function
type.
Jul 19 '05 #3
On Tue, 19 Aug 2003 13:23:58 -0400, "Ron Natalie" <ro*@sensor.com> wrote:

"Alf P. Steinbach" <al***@start.no> wrote in message news:3f****************@News.CIS.DFN.DE...
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
int dummy1 = DIMM,
int dummy2 = DIMN
)

I don't think this one will work. If the compiler relies on the function signature
to differentiate the template specializations, then it still fails.
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
int dummy1[DIMM] = 0,
int dummy2[DIMN] = 0
)


I don't think this will work either, the arrays are converted to int* to form the function
type.


Well, what "used" means obviously depends on the (erronous) compiler.

But how about
template< int N >
struct Dummy
{
Dummy( int ) {}
};

template <class PT1, class PT2, class MAT, int DIMM, int DIMN>
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
Dummy<DIMM> dummy1 = 0,
Dummy<DIMN> dummy2 = 0
)
{
}

?

Of course, the best solution for the OP would be to use both a better
compiler and a better library, if possible.

Jul 19 '05 #4

"Alf P. Steinbach" <al***@start.no> wrote in message news:3f****************@News.CIS.DFN.DE...


Well, what "used" means obviously depends on the (erronous) compiler.

But how about
template< int N >
struct Dummy
{
Dummy( int ) {}
};

template <class PT1, class PT2, class MAT, int DIMM, int DIMN>
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
Dummy<DIMM> dummy1 = 0,
Dummy<DIMN> dummy2 = 0
)
{
}


That one looks better.
Another solution would be to wrap the function in a class that depends on the
template args.
Jul 19 '05 #5
On Tue, 19 Aug 2003 13:36:16 -0400, "Ron Natalie" <ro*@sensor.com> wrote:

"Alf P. Steinbach" <al***@start.no> wrote in message news:3f****************@News.CIS.DFN.DE...


Well, what "used" means obviously depends on the (erronous) compiler.

But how about
template< int N >
struct Dummy
{
Dummy( int ) {}
};

template <class PT1, class PT2, class MAT, int DIMM, int DIMN>
inline void mulPointMatrix(
PT1& res,
PT2 const& p,
MAT const& m,
Dummy<DIMM> dummy1 = 0,
Dummy<DIMN> dummy2 = 0
)
{
}


That one looks better.
Another solution would be to wrap the function in a class that depends on the
template args.


If the library can be redesigned then _much_ better solutions exist. Keeping
the "fixed size matrix type" idea the size should be deducible from the type.
Even better, if possible allow mixture of fixed-size and dynamic-size with
compile time checking where all necessary information is available (now that
is, I think, a nice design problem -- is it possible to do in a clean way?).

But the intent was to not require any changes to existing client code.

Jul 19 '05 #6


Of course, the best solution for the OP would be to use both a better
compiler and a better library, if possible.


Thanks for all of the info guys...
Sadly enough, I can't get a better library (what I have is what I get). :(

However, it seems to me that you think a newer version of the compiler
(MIPSpro) may do the trick. Is this the case?

Thanks again,
Adam
Jul 19 '05 #7

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

Similar topics

4
by: Mat DeLong | last post by:
I have never been stuck on programming something before to the point I give up... this is a first. I am programming what should be something very easy in C++... using Templates. Here is the code,...
3
by: Chris | last post by:
I am having a very strange problem involving virtual functions in template classes. First of all, here is an extremely simplified structure of the two classes I am having problems with. ...
1
by: ranges22 | last post by:
****************************************************************** I am compiling a librarry which has a .h file containing th following:...
2
by: Rudy Ray Moore | last post by:
Whenever I get any error with Vc++7.1/.net/2003, it is followed by huge ammounts of "template assistance" error messaging referencing template code (MTL) that has nothing to do with the error. ...
2
by: Greg Buchholz | last post by:
/* I've been experimenting with some generic/polytypic programs, and I've stumbled on to a problem that I can't quite figure out. In the program below, I'm trying to define a generic version of...
2
by: pagekb | last post by:
Hello, I'm having some difficulty compiling template classes as containers for other template objects. Specifically, I have a hierarchy of template classes that contain each other. Template...
3
by: Hamilton Woods | last post by:
Diehards, I developed a template matrix class back around 1992 using Borland C++ 4.5 (ancestor of C++ Builder) and haven't touched it until a few days ago. I pulled it from the freezer and...
8
by: Jess | last post by:
Hi, I have a template function that triggered some compiler error. The abridged version of the class and function is: #include<memory> using namespace std; template <class T>
2
by: Barry | last post by:
The following code compiles with VC8 but fails to compiles with Comeau online, I locate the standard here: An explicit specialization of any of the following:
7
by: QiongZ | last post by:
Hi, I just recently started studying C++ and basically copied an example in the textbook into VS2008, but it doesn't compile. I tried to modify the code by eliminating all the templates then it...
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: 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
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...
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.