Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / December 2004

Tip: Looking for answers? Try searching our database.

LNK2022

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Steve Marsden - 01 Dec 2004 17:35 GMT
Hi

I have a project which uses some C code and some C++ code. I have a
structure I want to use in both the C code and the  C++ code. I have this
structure defined in an include file which I have included in the C file and
the C++ file.

The project is compiled with /clr and compiles OK but when it links I get:

Error LNK2022 metadata operation failed (8013118D) : Inconsistent layout
information in duplicated types (job_mdb_item): (0x0200000b)

The types are not duplicated. The structure job_mdb_item is only declared
once in the include file but I assume it is getting compiled differently in
the C++ file than it is in the C file so the end result is the error caused
here.

How can I ensure that it is complied the same in the C++ file as it is in
the C file to avoid this error. I am experienced in C but new to C++ and
managed C++

Thanks

Steve
Carl Daniel [VC++ MVP] - 01 Dec 2004 17:47 GMT
> Hi
>
[quoted text clipped - 16 lines]
> the C file to avoid this error. I am experienced in C but new to C++ and
> managed C++

In your C++ file (but not your C file), instead of

#include "job_mdb.h"

use

extern "C" {
#include "job_mdb.h"
}

Alternatively, inside your header file you can use

#ifdef __cplusplus
extern "C" {
#endif

struct job_mdb
{
 //...
};

#ifdef __cplusplus
}
#endif

HTH

-cd
Steve Marsden - 02 Dec 2004 10:22 GMT
Hi Carl

Thanks for the reply.

Sadly this doesnt work. I still get the same linker error.

Steve

>> Hi
>>
[quoted text clipped - 46 lines]
>
> -cd

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.