By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,679 Members | 2,763 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,679 IT Pros & Developers. It's quick & easy.

Linking problem - bug? please help.

P: n/a
Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++ 2003.

Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations in duplicated
types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test case and
due to time constraints I had to leave the problem. I had
another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seems perfectly
legal to me.

Does anyone have any idea what is going on here?

thanks.

Gary.
Nov 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Gary Hughes wrote:
Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++ 2003.

Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations in duplicated
types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test case and
due to time constraints I had to leave the problem. I had
another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seems perfectly
legal to me.

Does anyone have any idea what is going on here?


There's more to it than what you posted. Taking your sample code above and
making it into a complete program:

#using <mscorlib.dll>

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

int main()
{
GCClass* g = new GCClass;
}

compiing with cl -clr compiles and links without incident. Can you post a
complete example along with compiler command-line options?

-cd
Nov 16 '05 #2

P: n/a
-----Original Message-----
Gary Hughes wrote:
Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++ 2003.
Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations in duplicated types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test case and due to time constraints I had to leave the problem. I had another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seems perfectly legal to me.

Does anyone have any idea what is going on here?
There's more to it than what you posted. Taking your

sample code above andmaking it into a complete program:

#using <mscorlib.dll>

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

int main()
{
GCClass* g = new GCClass;
}

compiing with cl -clr compiles and links without incident. Can you post acomplete example along with compiler command-line options?

-cd
.


Sorry Carl, one thing I did not mention main() needs to be
in a separate file the class #included. I can send you a
complete project if you like. If the whole thing is in a
single cpp file it works correctly as you found.

Gary.
Nov 16 '05 #3

P: n/a
Gary Hughes wrote:
Sorry Carl, one thing I did not mention main() needs to be
in a separate file the class #included. I can send you a
complete project if you like. If the whole thing is in a
single cpp file it works correctly as you found.


ZIP it up and post it here, or you can email to me - your choice. Do the
obvious things to my reply-to address to get a real email address.

-cd
Nov 16 '05 #4

P: n/a
i work with c++ team, i created two files, one header file with your class
and one cpp which #Includes the header, but we cannot repro it.
It will be great if you can send the repro project to my email address.
(remove the online ,from my address) or post a better repro. We would like
to understand as to why this doesn't work.
Mahesh
--------------------
Content-Class: urn:content-classes:message
From: "Gary Hughes" <ge*@itga.com.au.NOSPAM>
Sender: "Gary Hughes" <ge*@itga.com.au.NOSPAM>
References: <07****************************@phx.gbl> <OU**************@TK2MSFTNGP11.phx.gbl>Subject: Re: Linking problem - bug? please help.
Date: Sun, 26 Oct 2003 19:27:11 -0800
Lines: 103
Message-ID: <04****************************@phx.gbl>
MIME-Version: 1.0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
Thread-Index: AcOcOjW1YYj2fjzUSJeDNUBJ8gfyXA==
Newsgroups: microsoft.public.dotnet.languages.vc
Path: cpmsftngxa06.phx.gbl
Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vc:29763
NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
X-Tomcat-NG: microsoft.public.dotnet.languages.vc

-----Original Message-----
Gary Hughes wrote:
Hi all, sometime I posted a problem in here where I was
getting the following error from the linker in VS C++2003.
Linking...
GCClass.obj : error LNK2022: metadata operation failed
(80131188) : Inconsistent field declarations induplicated types (types: GCClass; fields: m_blah): (0x04000001).
LINK : fatal error LNK1215: metadata operation failed
(80131130) :

At the time I was unable to produce a simple test caseand due to time constraints I had to leave the problem. Ihad another go at it today and was able to produce a simple
test case. The code follows:

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

If I attempt to instantiate GCClass as follows I get the
error above.

GCClass* g = new GCClass;

There are two things I can do to get rid of the error:

1. put the dog class outside the itga namespace.
2. not make the dog class a template.

Neither of these is possible nor desirable as I'm just
trying to wrap a heap of existing C++ code in .NET
wrappers and as far as I am concerned this seemsperfectly legal to me.

Does anyone have any idea what is going on here?


There's more to it than what you posted. Taking your

sample code above and
making it into a complete program:

#using <mscorlib.dll>

namespace itga
{

template<typename Type>
class dog
{
public:
class blah {};
};

}

public __gc class GCClass
{
itga::dog<int>::blah* m_blah;
};

int main()
{
GCClass* g = new GCClass;
}

compiing with cl -clr compiles and links without

incident. Can you post a
complete example along with compiler command-line options?

-cd
.


Sorry Carl, one thing I did not mention main() needs to be
in a separate file the class #included. I can send you a
complete project if you like. If the whole thing is in a
single cpp file it works correctly as you found.

Gary.


Nov 16 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.