473,624 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A potential bug? (- warning LNK4227)

Hi,

I've been recently porting some software written under
VC++ 6.0 to VC .NET. The software was compiling fine
under 6.0 but under .NET I'm getting linker warning:

b.obj : warning LNK4227: metadata operation warning
(00131189) : Inconsistent parameter information in
duplicated methods (methods: new; type: <Module>):
(0x08000005).

I tried to isolate the problem. I created simple
project Test - console application. The only thing
I changed in project settings was disabling the use
of precompiled headers.

There are also three other files: a.h (template Ta)
and b.h/b.cpp (class Cb). Below is the source code.

When I compile the whole project, I'm getting linker
warning LNK4227. The interesting thing is that when
the method Alloc() of Ta is not "virtual" (delete
"virtual" word) everything compiles and links without
problem. Similarly, when the method's body contains
only "return m_pT = new T;" and the function remains
"virtual" the linker doesn't have any problem.

But I do need to use "malloc" and "new() T" for
_separate_ memory allocation and object
initialization (in real code), and the method
Alloc() must be virtual...

Does anyone know what am I doing wrong? How can
setup the compiler or fix the code to get rid of
the warning? Or maybe there is a bug in VC++?

I would greatly appreciate your suggestions.

Thanks,
Piotr Balcerzak
Test.cpp
-----------------------------------------------------------------
// This is the main project file for VC++ application project
// generated using an Application Wizard.

#include "stdafx.h"
#include "a.h"

#using <mscorlib.dll >
using namespace System;

int _tmain()
{
a<char> xyz;

Console::WriteL ine(S"Hello World");
return 0;
}
-----------------------------------------------------------------

a.h
-----------------------------------------------------------------
#include <wtypes.h>
#include <new.h>

template<class T>
class Ta
{
private:
T* m_pT; //memory block containing objects

public:
Ta() : m_pT(NULL) {}
virtual ~Ta() { Free(); }

virtual T* Alloc(void) //allocate memory
{
m_pT = (T*)malloc(size of(T));
if (m_pT != NULL) new (m_pT) T; //call constructor
return m_pT;

// return m_pT = new T; //works here but is useless in my code
}

virtual void Free(void) //free memory
{
if (m_pT != NULL)
{
m_pT->~T(); //call destructor
free(m_pT);
}
}
};
-----------------------------------------------------------------

b.h
-----------------------------------------------------------------
#include "a.h"

class Cb
{
private:
Ta<char> x;

public:
Cb();
~Cb();
};
-----------------------------------------------------------------

b.cpp
-----------------------------------------------------------------
#include "b.h"

Cb::Cb()
{
int i = 0;
}

Cb::~Cb()
{
int i = 0;
}
-----------------------------------------------------------------
Nov 16 '05 #1
0 1731

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

Similar topics

1
12142
by: Marc Schellens | last post by:
Including Python.h I got the following warining warning: "_POSIX_C_SOURCE" redefined in Python.h: #define _POSIX_C_SOURCE 200112L in features.h (included from string):
27
4746
by: MK | last post by:
I am a newbie. Please help. The following warning is issued by gcc-3.2.2 compiler (pc Linux): ================================================================== read_raw_data.c:51: warning: assignment makes pointer from integer without a cast ================================================================== when the following piece of code was compiled. The offending statement is calloc. A similar statement in the main() function...
2
1985
by: Hovik Melikyan | last post by:
This code produces a 'unreachable code' warning at line 16 (throw new X ...) with no visible reason: #include <string> class X { std::string msg;
3
2037
by: cody | last post by:
I got a warning from fxcop from the declararation of a struct. the warning: "Structures with explicit layout containing misaligned fields cause crashes on 64 bit platforms" the struct:
1
3592
by: Boris | last post by:
When I compile my "mixed-mode" C++ dll in Release mode, I get these warnings - LINK : warning LNK4243: DLL containing objects compiled with /clr is not linked with /NOENTRY; image may not run correctly LINK : warning LNK4089: all references to 'MSVCP71.dll' discarded by /OPT:REF LINK : warning LNK4089: all references to 'OLEAUT32.dll' discarded by /OPT:REF LINK : warning LNK4089: all references to 'USER32.dll' discarded by /OPT:REF
0
1391
by: Andrew | last post by:
I have a native c++ application that I built with the /clr compiler option. When the application is linked, I receive the following warnings: FaddClient.obj : warning LNK4227: metadata operation warning (00131189) : Inconsistent parameter information in duplicated methods (methods: _bstr_t.__ctor; type: <Module>): (0x08000005). FaddClient.obj : warning LNK4227: metadata operation warning (00131189) : Inconsistent parameter...
1
1519
by: wanglei0214 | last post by:
I compiles a program in SLOS, but there is a warning i donot know how to remove? here is the framework of the code: typedef struct device_tree { ...... union {
8
2003
by: Charles Sullivan | last post by:
I have a program written in C under Linux (gcc) which a user has ported to run under AT&T SysV R4. He sent me a copy of his makelog which displays a large number of compiler warnings similar to this: warning: semantics of ">>" change in ANSI C; use explicit cast The statement to which this applies is: xuc = ((uc & 0xF0 ) >4);
20
3239
by: jacob navia | last post by:
Consider this code static typedef struct { int boo; } FOO; This provokes with MSVC: ------------------------------ Microsoft (R) C/C++ Optimizing Compiler Version 14.00.50727.762 for x64 Copyright (C) Microsoft Corporation. All rights reserved.
0
8236
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
8173
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
8679
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...
1
8335
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
7159
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...
1
6110
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4079
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...
1
2606
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
2
1482
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.