[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: More information about inline function "used but never defined" erro
From: |
Paul Pluzhnikov |
Subject: |
Re: More information about inline function "used but never defined" error? |
Date: |
15 Feb 2005 16:38:23 -0800 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Artificial Intelligence) |
john.pye@gmail.com writes:
> I had not come across that need to have "template<>" in there. Where do
> you say I need to put that?
Exactly where I put it. Correct syntax is:
template <>
inline Units<0,0,0,0,0>::operator double() const
{
return d_val;
}
Without the 'template<>' gcc-4.0 will refuse to compile your code.
> Also, I have been able to get those linker errors but I want to somehow
> get more information about the location of the attempted cast to
> double. Ideally this should throw a compiler error rather than a linker
> error. By changing the undefined operator double() to "inline" I have
> been able to get a compiler *warning* but it still doesn't give the
> location in the code where invalid cast double is occurring.
I am not getting any warnings from your code.
Which versions of g++ are you using?
> The example I gave with 'upsilon' is a very simple one, and I
> understand that one already.
I see. Here is one way to get "more exact" location of the problem.
Arguably this is not very elegant, but it works.
Make the 'operator double() const' private in units.h:
... private: operator double() const; public: ...
Then compiling your original test produces the exact problem location
you are after, e.g.:
$ /usr/local/gcc-3.2/bin/g++ -c units-04.cfail.cpp
units.h: In function `int main()':
units.h:82: `Units<M, L, T, K, I>::operator double() const [with int M = 0,
int
L = 0, int T = 0, int K = 1, int I = 0]' is private
units-04.cfail.cpp:16: within this context
units.h:82: `Units<M, L, T, K, I>::operator double() const [with int M = 0,
int
L = 0, int T = 0, int K = 1, int I = 0]' is private
units-04.cfail.cpp:16: within this context
Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.