One think I really dislike about the (default?) behavior of gcc is the way
it prints errors to console. This is one such report:
cd /home/hattons/code/c++/sth/vmath/test/ # -*-compilation-*-
Entering directory `/home/hattons/code/c++/sth/vmath/test/'
g++ -o testMatrix3 testMatrix3.cc -I/home/hattons/code/c++
In file included from Matrix3Test.hh:4,
from testMatrix3.cc:1:
/home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: prototype for `const
sth::vmath::IndexedReference<T, sth::vmath::Matrix3<T>::ORDER>&
sth::vmath::Matrix3<T>::operator[](const unsigned int&) const' does not
match any in class `sth::vmath::Matrix3<T>'
/home/hattons/code/c++/sth/vmath/Matrix3.hh:96: error: candidate is: const
sth::vmath::IndexedReference<T, sth::vmath::Matrix3<T>::ORDER>&
sth::vmath::Matrix3<T>::operator[](const unsigned int&) const
/home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: template definition
of
non-template `const sth::vmath::IndexedReference<T,
sth::vmath::Matrix3<T>::ORDER>& sth::vmath::Matrix3<T>::operator[](const
unsigned int&) const'
Compilation exited abnormally with code 1 at Fri Oct 8 19:32:56
Now for the fun part. Read the message closely. What it boils down to is
this:
The first line is wrong. You should have used the second line:
IndexedReference<T, Matrix3<T>::ORDER>& Matrix3<T>::operator[](int&)
IndexedReference<T, Matrix3<T>::ORDER>& Matrix3<T>::operator[](int&)
Now here's what the problem was. I have a static const unsigned ORDER = 3
in Matrix3<T>. When I try to use that as a template parameter in the
definition of a member function the compiler gets confused. Likewise if I
try to use an enum. And I did qualify it where I used it outside the class
definition.
Anybody want to try and explain /that/?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell 7 1654
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote in message
news:zu********************@speakeasy.net... One think I really dislike about the (default?) behavior of gcc is the way it prints errors to console. This is one such report:
cd /home/hattons/code/c++/sth/vmath/test/ # -*-compilation-*- Entering directory `/home/hattons/code/c++/sth/vmath/test/' g++ -o testMatrix3 testMatrix3.cc -I/home/hattons/code/c++ In file included from Matrix3Test.hh:4, from testMatrix3.cc:1: /home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: prototype for
`const sth::vmath::IndexedReference<T, sth::vmath::Matrix3<T>::ORDER>& sth::vmath::Matrix3<T>::operator[](const unsigned int&) const' does not match any in class `sth::vmath::Matrix3<T>' /home/hattons/code/c++/sth/vmath/Matrix3.hh:96: error: candidate is: const sth::vmath::IndexedReference<T, sth::vmath::Matrix3<T>::ORDER>& sth::vmath::Matrix3<T>::operator[](const unsigned int&) const /home/hattons/code/c++/sth/vmath/Matrix3.hh:141: error: template
definition of non-template `const sth::vmath::IndexedReference<T, sth::vmath::Matrix3<T>::ORDER>&
sth::vmath::Matrix3<T>::operator[](const unsigned int&) const'
Compilation exited abnormally with code 1 at Fri Oct 8 19:32:56
Now for the fun part. Read the message closely. What it boils down to is this:
The first line is wrong. You should have used the second line: IndexedReference<T, Matrix3<T>::ORDER>& Matrix3<T>::operator[](int&) IndexedReference<T, Matrix3<T>::ORDER>& Matrix3<T>::operator[](int&)
Now here's what the problem was. I have a static const unsigned ORDER = 3 in Matrix3<T>. When I try to use that as a template parameter in the definition of a member function the compiler gets confused. Likewise if I try to use an enum. And I did qualify it where I used it outside the
class definition.
Anybody want to try and explain /that/?
Not here. Here we discuss the language, not the operation
or idiosyncracies of any particular implementation, nor the
deciphering of diagnostic messages. The language does not
mandate any particular form for diagnostic messages, only
that 'a diagnostic' be issued upon encountering certain language
violations. E.g. if you supply the wrong number of arguments to
a function, it's valid for a compiler to complain: "your dog
has fleas". If you're unhappy with the behavior of a compiler
your recourses are to complain to the vendor, or use (or create)
something else.
I have many times seen folks deride a compiler (or other piece
of software), but none has ever claimed to be able to create
anything superior (I've taken to calling this the "Microsoft
Windows Syndrome". There, I feel better now. :-)
I think you've been reading and posting here long enough to realize
that your message is not topical here. If you want to pursue this,
please take it to a gcc group or mailing list. www.gcc.gnu.org
-Mike
Mike Wahler wrote: I think you've been reading and posting here long enough to realize that your message is not topical here. If you want to pursue this, please take it to a gcc group or mailing list.
www.gcc.gnu.org
-Mike
Why don't you address the part that /is/ about the language rather than
trying to play c.l.c++ policeman? Here it is again for your convenience:
Now here's what the problem was.**I*have*a*static*const*unsigned*ORDER*=*3
in Matrix3<T>.**When*I*try*to*use*that*as*a*template* parameter*in*the
definition of a member function the compiler gets confused.**Likewise*if*I
try to use an enum.**And*I*did*qualify*it*where*I*used*it*outsid e*the*class
definition.
Anybody want to try and explain /that/?
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote... [...] Now here's what the problem was. I have a static const unsigned ORDER = 3 in Matrix3<T>. When I try to use that as a template parameter in the definition of a member function the compiler gets confused. Likewise if I try to use an enum. And I did qualify it where I used it outside the class definition.
Anybody want to try and explain /that/?
Can you use C++ to show the problem instead of trying to explain
in English? Many of us here understand C++ better than English,
you know.
So:
#include <iostream>
namespace sth {
namespace vmath {
template<class T> class Matrix3 {
static const unsigned ORDER = 3;
public:
template<unsigned N> void foo();
};
template<class T> template <unsigned N>
void Matrix3<T>::foo() {
// who cares
for (int i = 0; i < ORDER; ++i)
std::cout << "beep!";
}
}
}
int main() {
sth::vmath::Matrix3<double> m;
m.foo<2>();
}
Is that something you have a problem with? Comeau compiles it fine.
G++ v 3.2.2 does just as well. If that's not it, how about reading
the FAQ for a change? 5.8 should be right about what you need.
V
Victor Bazarov wrote: "Steven T. Hatton" <su******@setidava.kushan.aa> wrote... [...] Now here's what the problem was. I have a static const unsigned ORDER = 3 in Matrix3<T>. When I try to use that as a template parameter in the definition of a member function the compiler gets confused. Likewise if I try to use an enum. And I did qualify it where I used it outside the class definition.
Anybody want to try and explain /that/?
Can you use C++ to show the problem instead of trying to explain in English? Many of us here understand C++ better than English, you know.
#include <iostream>
//#define BROKEN
#ifndef BROKEN
#define REDRO 3
#define REDRO2 REDRO
#else
#define REDRO ORDER
#define REDRO2 C<T>::ORDER
#endif
namespace sth{
template <typename T, unsigned N>
struct S
{
S():n(N){}
T n;
std::ostream& print(std::ostream& out) const
{
return out << "The value of n is:" << n << "\n";
}
};
template<typename T>
class C {
public:
static const unsigned ORDER=3;
const S<T, REDRO>& gimmie_s() const;
protected:
S<T, REDRO> _s;
};
template <typename T>
const S<T, REDRO2>& C<T>::gimmie_s() const
{
return _s;
}
}
int main()
{
sth::C<float> c;
c.gimmie_s().print(std::cout);
}
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote... Victor Bazarov wrote:
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote... [...] Now here's what the problem was. I have a static const unsigned ORDER = 3 in Matrix3<T>. When I try to use that as a template parameter in the definition of a member function the compiler gets confused. Likewise if I try to use an enum. And I did qualify it where I used it outside the class definition.
Anybody want to try and explain /that/?
Can you use C++ to show the problem instead of trying to explain in English? Many of us here understand C++ better than English, you know.
#include <iostream> //#define BROKEN #ifndef BROKEN
#define REDRO 3 #define REDRO2 REDRO
#else
#define REDRO ORDER #define REDRO2 C<T>::ORDER
#endif
namespace sth{ template <typename T, unsigned N> struct S { S():n(N){} T n; std::ostream& print(std::ostream& out) const { return out << "The value of n is:" << n << "\n"; } };
template<typename T> class C { public: static const unsigned ORDER=3;
const S<T, REDRO>& gimmie_s() const;
protected: S<T, REDRO> _s;
};
template <typename T> const S<T, REDRO2>& C<T>::gimmie_s() const { return _s; } }
int main() { sth::C<float> c; c.gimmie_s().print(std::cout); }
OK, when 'BROKEN' is defined, the program compiles with Comeau (online
trial) but doesn't with some other compilers, I take it. MIPSpro gets
it right too, BTW.
So, ultimately your problem is with G++, and your beef with Mike was
unfounded. Post to gnu.g++.help
Victor
Victor Bazarov wrote: OK, when 'BROKEN' is defined, the program compiles with Comeau (online trial) but doesn't with some other compilers, I take it. MIPSpro gets it right too, BTW.
So, ultimately your problem is with G++, and your beef with Mike was unfounded. Post to gnu.g++.help
Victor
The last time that argument was given, I ended up sending mail the Bjarne
Stroustrup telling him about the problem with his code. http://gcc.gnu.org/ml/gcc/2004-04/msg01268.html
--
"If our hypothesis is about anything and not about some one or more
particular things, then our deductions constitute mathematics. Thus
mathematics may be defined as the subject in which we never know what we
are talking about, nor whether what we are saying is true." - Bertrand
Russell
"Steven T. Hatton" <su******@setidava.kushan.aa> wrote... Victor Bazarov wrote:
OK, when 'BROKEN' is defined, the program compiles with Comeau (online trial) but doesn't with some other compilers, I take it. MIPSpro gets it right too, BTW.
So, ultimately your problem is with G++, and your beef with Mike was unfounded. Post to gnu.g++.help
Victor
The last time that argument was given, I ended up sending mail the Bjarne Stroustrup telling him about the problem with his code.
What kind of "argument" are you looking for? The code is supposed to
compile. And it does with at least two compilers I've tried. What else?
Was that code from a book or something? What? If you want to get to
the bottom of it, you will have to give more information. If you want
to play games, count me out.
V This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: lkrubner |
last post by:
This is a general computer question, but I'm writing in PHP so I'll
post this to comp.lang.php.
I've been writing a content management system. I've a Singleton object
that keeps track of all...
|
by: Steve |
last post by:
Hi;
I went to the microsoft site to try to find a guide to the error
messages that the jdbc drivers give ( for sqlserver 2000 ).
I had no luck.
Does anyone know if there is such a guide?
...
|
by: DataBard007 |
last post by:
Hello Access Gurus:
I use Win98SE and Access97.
I just built a simple Access97 application which holds all contact
information for my personal contacts, such as first name, last name,
address,...
|
by: Brian Conway |
last post by:
I have no idea what is going on. I have a Login screen where someone types
in their login information and this populates a datagrid based off of the
login. Works great in debug and test through...
|
by: Janning Vygen |
last post by:
Hi,
i have a question about how to handle postgresql constraint errors in
the client app. I found some mails in the archive about it, too. But
i have still so many questions about how to do it,...
|
by: Brian Tkatch |
last post by:
Server: DB2/SUN 8.1.6
Client: DB2 Connect Personal Edition (No 11)
<URL:ftp://ftp.software.ibm.com/ps/products/db2/fixes2/english-us/db2winIA32v8/fixpak/FP11_WR21365/FP11_WR21365_CONPE.exe>
...
|
by: lawrence k |
last post by:
I've made it habit to check all returns in my code, and usually, on
most projects, I'll have an error function that reports error messages
to some central location. I recently worked on a project...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: FutureShock |
last post by:
I am using a registration class to process a registration form and need
some opinions on returning error messages.
I am self referring the page on submit.
I would like to send each form field...
|
by: hyperpau |
last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding.
I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com).
Ergo, I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |