473,761 Members | 6,563 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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/gstGenericMatri x.h", line 115:
error(1424):
constant "DIMM" is not used in declaring the parameter types of
function template "gstGenericMatr ix::mulPointMat rix"
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 1640
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/gstGenericMatri x.h", line 115:
error(1424):
constant "DIMM" is not used in declaring the parameter types of
function template "gstGenericMatr ix::mulPointMat rix"
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.C IS.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.C IS.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.C IS.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.C IS.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
2580
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, and the error I get: -------------- namespace LIST { template <typename T> struct Link; template <typename T> class List;
3
3939
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. template<class Type> class base { public: base& operator/=(const base&); Type *image;
1
1990
by: ranges22 | last post by:
****************************************************************** I am compiling a librarry which has a .h file containing th following: ****************************************************************** template<typename T> void from_string(const char Str, T &Obj); template<> void from_string(const char Str, long &); // template<> void from_string(const char Str, unsigned lon &); //
2
2019
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. This makes it difficult to spot errors. For example, F4 to "jump to next error" just jumps ot the next "template assistance" message. And since there are hundreds of them, this is quite obnoxious. Can I disable these things? Why is MSVC...
2
1978
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 "transform" which works not only on lists, but lists of list, lists of lists of lists, etc. I'm calling it "fmap" and it passes around actual lists instead of iterators (for now). In order to get it to work, I thought I'd have one templated...
2
3343
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 class B has an instance of template class A, which has some base type T (usually int or double). However, the base type T is important to calculations in B, so I would like to obtain access to the type for further variable declaration within B. ...
3
3758
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 thawed it out. I built a console app using Microsoft Visual C++ 6 (VC++) and it worked great. Only one line in the header file had to be commented out. I built a console app using Borland C++ Builder 5. The linker complained of references to...
8
5316
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
7698
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
5772
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 compiled no problem. But I can't find the what the problem is with templates? Please help. The main is in test-linked-list.cpp. There are two template classes. One is List1, the other one is ListNode. The codes are below: // test-linked-list.cpp :...
0
9336
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10111
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
9948
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...
1
9902
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9765
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
8770
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...
0
6603
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();...
0
5364
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3866
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.