Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Functions - C and C++ compatibility

Status
Not open for further replies.

alanmusician

Programmer
Jun 30, 2005
17
US
I have a function that I've written in C++ that I need to make available in a project that will only compile with the /TC option (crappy casting). What is the easiest way to solve this problem?
 
Just declare it as extern "C". This means that the prototype is in C. The implementation can be whatever you like.
 
Okey, everything works peachy when I plug it into another test project I built that uses the /TC switch, but I get this error with the real project:

LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library

Any ideas?
 
LIBCMT is the multi-threaded C library. Make sure you build all libraries with the same setting. The following settings should be the same

1) release/debug (D suffix)
2) single/multi threaded (MT suffix)

i.e.

libc - release single threaded
libcd - debug single threaded
libcmt - release multi threaded
libcmtd - debug multi threaded
 
They're all using LIBCMT. When I add my C++ module to the project I get these errors. All it #includes is windows.h and fstream.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top