473,785 Members | 2,308 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

"unable to match function definition to an existing declaration"

Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iter ator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>: :TableType::ite rator
MarkerTable<T>: :FindErr( unsigned long n )
{
typename TableType::iter ator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T> ::FindErr' : unable to match function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T> ::FindErr'
definition
'std::vector<T, T2>::iterator MarkerTable<T>: :FindErr(unsign ed long)'
existing declarations
'vector<Marker< T>>::iterator MarkerTable<T>: :FindErr(unsign ed long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett
Sep 10 '05 #1
5 6343

"Maett" <no@spam.pls> wrote in message news:opswv68avt mmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iter ator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>: :TableType::ite rator
MarkerTable<T>: :FindErr( unsigned long n )
{
typename TableType::iter ator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
Your code compiles OK for me with VC++ v6.0(SP6).


I get the error
line 28 : error C2244: 'MarkerTable<T> ::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T> ::FindErr'
definition
'std::vector<T, T2>::iterator MarkerTable<T>: :FindErr(unsign ed
long)'
T2? I don't see that anywhere in your posted code.
Have you made a typo somewhere and the above isn't the real code? :-)

existing declarations
'vector<Marker< T>>::iterator MarkerTable<T>: :FindErr(unsign ed
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?


-Mike
Sep 10 '05 #2

"Maett" <no@spam.pls> wrote in message news:opswv68avt mmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iter ator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>: :TableType::ite rator
MarkerTable<T>: :FindErr( unsigned long n )
{
typename TableType::iter ator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T> ::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T> ::FindErr'
definition
'std::vector<T, T2>::iterator MarkerTable<T>: :FindErr(unsign ed
long)'
existing declarations
'vector<Marker< T>>::iterator MarkerTable<T>: :FindErr(unsign ed
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett


Looks like a compiler bug. VC++ 2005 Beta 2 compiles the code just fine.

Ben
Sep 10 '05 #3
Mike Wahler:

"Maett" <no@spam.pls> wrote in message news:opswv68avt mmfhfz@max...
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iter ator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>: :TableType::ite rator
MarkerTable<T>: :FindErr( unsigned long n )
{
typename TableType::iter ator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
Your code compiles OK for me with VC++ v6.0(SP6).


For me the code also compiled ok with VC++ 6.0 (SP5);
I'm migrating to VC++.NET 2003.


I get the error
line 28 : error C2244: 'MarkerTable<T> ::FindErr' : unable to match
function
definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T> ::FindErr'
definition
'std::vector<T, T2>::iterator MarkerTable<T>: :FindErr(unsign ed
long)'
T2? I don't see that anywhere in your posted code.
Have you made a typo somewhere and the above isn't the real code? :-)


Unfortunately it really *is* what VC says.
I don't use T2; no idea where the compiler takes it from.

existing declarations
'vector<Marker< T>>::iterator MarkerTable<T>: :FindErr(unsign ed
long)'

Comeau compiles with no error.
Can you tell me what I'm doing wrong ?


-Mike


Maett
Sep 10 '05 #4
"Maett" <no@spam.pls> wrote in message news:opswv68avt mmfhfz@max
Hi.

When I try to compile this piece of Code with VC.NET 2003

// code start
#include <vector>

template< class T > struct Marker
{
public:
Marker() : err( 0 ) {}
unsigned long err;
};

template< class T > struct MarkerTable
{
public:
typedef std::vector< Marker<T> > TableType;
TableType data;
typename TableType::iter ator FindErr( unsigned long ); // line 15
};

template< class T >
typename MarkerTable<T>: :TableType::ite rator
MarkerTable<T>: :FindErr( unsigned long n )
{
typename TableType::iter ator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
} // line 28
// code end
I get the error
line 28 : error C2244: 'MarkerTable<T> ::FindErr' : unable to match
function definition to an existing declaration
line 15 : see declaration of 'MarkerTable<T> ::FindErr'
definition
'std::vector<T, T2>::iterator MarkerTable<T>: :FindErr(unsign ed
long)' existing declarations
'vector<Marker< T>>::iterator MarkerTable<T>: :FindErr(unsign ed
long)'
Comeau compiles with no error.
Can you tell me what I'm doing wrong ?

Maett


Apparently it is a VC++2003 bug. You can work around it by not using the
typedef from MarkerTable when defining FindErr, i.e., make it:

template< class T >
typename std::vector< Marker<T> >::iterator
MarkerTable<T>: :FindErr( unsigned long n )
{
typename TableType::iter ator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
}

--
John Carson

Sep 11 '05 #5
John Carson wrote:

Apparently it is a VC++2003 bug. You can work around it by not using the
typedef from MarkerTable when defining FindErr, i.e., make it:

template< class T >
typename std::vector< Marker<T> >::iterator
MarkerTable<T>: :FindErr( unsigned long n )
{
typename TableType::iter ator iter
= lower_bound( data.begin(), data.end(), Marker<T>( 0, n ) );
if( ( data.end() != iter ) && ( (*iter).err != n ) ) {
iter = data.end();
}
return iter;
}


Great, this works.
Thanks a lot !

Maett
Sep 11 '05 #6

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

Similar topics

2
6195
by: Hartmut Sbosny | last post by:
Hello NG, I have a question. I have a header file with a function template and a fully specialized version of it, for instance //======== File "templ.hpp" ======== #include <iostream> // the general function template... template <class T>
10
20893
by: Kobu | last post by:
My question is about the use and meaning of the terms "declaration" and "definition" as it pertains to the C language. I've read sources that mix the two up when talking about such things as setting aside storage for an object, defining/declaring a struct, parts of a function, referencing an external variable in another module. sourcefile1.c ============== extern long globalfoo; /* declaration? */
4
11361
by: octavio | last post by:
Hello members of the comp.lang.c newsgroup. Please I need you help on the following one. Compiling the simple code I'm getting this error message. Why ? Please what's the correct type of the fb function ? Thank You. Octavio and.c:15: attention : type mismatch with previous implicit declaration and.c:11: attention : previous implicit declaration of `fb'
1
6125
by: sathyp | last post by:
Public Function SetPrinterDefaultsW(ByVal sPrinterName As String, _ ByVal nPaperSize As Long, ByVal nOrientation As Long) As Boolean Dim Prn As Printer Dim hPrinter As Long Dim pd As PRINTER_DEFAULTS Dim pinfo2 As PRINTER_INFO_2 Dim pinfo8 As PRINTER_INFO_8 Dim pinfo9 As PRINTER_INFO_9 Dim dm As DEVMODEW Dim yDevModeData() As Byte
33
25226
by: Chen shuSheng | last post by:
I have a code: --------------------------- #include <iostream.h> #include <stdlib.h> int main() { int max=15; char line; getline(line,max); system("PAUSE");
12
2381
by: Jon Slaughter | last post by:
is there any way to simply add an attribute like feature to a function/method definition? say I create a function like function Test() { //.... }
3
2478
by: Good Man | last post by:
Hi there Ideally, I'd like to create one javascript function and pass the file extension i'm looking for to see if its there: <input type="file" onchange="checkFile('pdf',this)" /> and then have the function something like (w/ Prototype)
5
5928
by: Fred Hebert | last post by:
I was thinking of switching to VS2005, so I sent off for and received a 120 evaluation kit. This version was supposed to be the same as the full version, but the key limits you to 120 days. I installed it and began learning how to use it. I built several small C# test apps that use common classes in a dll that I also wrote. When I right click on a class that was defined in the dll and select "go to definition" it would open the source...
4
1472
by: DR | last post by:
when i build someone's project, and right click a function "goto definition" is disabled. how to reconfigure a .net project to support "goto definition" when i right click on function calls?
0
9646
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10346
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
10157
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...
0
9956
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
8982
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
5386
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5514
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4055
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
3
2887
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.