Help to solve LNK2022

T

Torben Laursen

I have tryed to use the cli switch on my C++ code

It is a large C++ project compiled to a dll that I call from a number of
different interfaces C++, VBA and C#

However when I try to compile with the CLI switch I get this error:

Error 3 error LNK2022: metadata operation failed (8013118D) : Inconsistent
layout information in duplicated types (Equia.cPhysical): (0x02000059).
Physical_Base.obj

The code that makes the error is very simply and I just dont see what is
wrong, can any one help me? The code is below

Thanks Torben

///Header file
#ifndef Physical_BaseH

#define Physical_BaseH

#include "Utility.h"

namespace Equia

{

class cPhysical_Base

{

public:

cPhysical_Base(void);

void Clear(void);

void Resize(const int &N);

std::vector<double> dni;

double value;

double dT;

double dP;

};

class cPhysical : public cPhysical_Base

{

public:

cPhysical(void);

void Clear(void);

void Resize(const int &N);

cPhysical_Base Residual;

cPhysical_Base Ideal;

};

class cPhysical_All

{

public:

cPhysical_All(void);

void Clear(void);

void Resize(const int &N);

cPhysical H;

cPhysical S;

cPhysical G;

cPhysical Cv;

cPhysical Cp;

};

} //namespace Equia

#endif



Code file:

#pragma hdrstop

#include "Physical_Base.h"

Equia::cPhysical_Base::cPhysical_Base(void)

{

Clear();

}

void Equia::cPhysical_Base::Clear(void)

{

value = 0.0;

dT = 0.0;

dP = 0.0;

for(unsigned int i=0; i<dni.size(); ++i)

dni = 0.0;

}

void Equia::cPhysical_Base::Resize(const int &N)

{

dni.resize(N);

}

Equia::cPhysical::cPhysical(void)

{

Clear();

}

void Equia::cPhysical::Clear(void)

{

cPhysical_Base::Clear();

Residual.Clear();

Ideal.Clear();

}

void Equia::cPhysical::Resize(const int &N)

{

cPhysical_Base::Resize(N);

Residual.Resize(N);

Ideal.Resize(N);

}

Equia::cPhysical_All::cPhysical_All(void)

{

}

void Equia::cPhysical_All::Clear(void)

{

H.Clear();

S.Clear();

G.Clear();

Cv.Clear();

Cp.Clear();

}

void Equia::cPhysical_All::Resize(const int &N)

{

H.Resize(N);

S.Resize(N);

G.Resize(N);

Cv.Resize(N);

Cp.Resize(N);

}
 
V

Vladimir Nesterovsky

I have tryed to use the cli switch on my C++ code
It is a large C++ project compiled to a dll that I call from a number of
different interfaces C++, VBA and C#

However when I try to compile with the CLI switch I get this error:

Error 3 error LNK2022: metadata operation failed (8013118D) : Inconsistent
layout information in duplicated types (Equia.cPhysical): (0x02000059).
Physical_Base.obj

This could happen if you have several translation units, and each uses a
different data alignment when your header file is included.
 
T

Torben Laursen

Hi Vladimir

Thanks, but I have no idear what you mean, can I get you to explan a bit

Thanks Torben
 
T

Torben Laursen

Hi Vladimir

Thanks

I have searched my code for #pragma pack and it is not in my code but it is
in a headerfile from a 3party vendor "Rainbow" and the code that is in that
file is:

File name: lserve.h

Top of file:
#if defined(_VMSWIN_) || defined (WIN32)

#pragma pack(push, 1)

#endif /*_VMSWIN_*/



End of file:

#if defined(_VMSWIN_) || defined (WIN32)

#pragma pack(pop)

#endif /*_VMSWIN_*/



However the 2 files are not related in any way (to the best of my knowledge)

But I have tried to comment out the code above and I get the same error, so
unless I have done something wrong the #pragma pack cannot be the root of
the problem.



Thanks for you help

Torben
 
V

Vladimir Nesterovsky

Thanks, but I have no idear what you mean, can I get you to explan a bit

Can you search "#pragma pack" in your sources? The same declarations in the
different translation units have to use the same packing alignment.

If you're not sure about include order of your header file you can use

#pragma pack(push, 4)

at the top of header, and

#pragma pack(pop)

at the bottom.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top