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++ / May 2005

Tip: Looking for answers? Try searching our database.

developing managed c++ library

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Achim Domma (Procoders) - 22 May 2005 20:50 GMT
Hi,

I try to develop a .Net class library using managed c++ and have several
problems:

- If I use operator new, I get a linker error because operator new is
missing. Searching the web I found out, that this is a well known
problem which has to do with the initialization of the C/C++ runtime
libraries. The proposed workaround looks not very promissing. But why
would somebody use managed C++ is you could not use common C++ features?

- I develop a library to work with AVI files. If I include windows.h and
wfw.h in different source units, I get a linker error concerning
metadata. Searching the web I found out that the reason seems to be,
that structures with the same name are defined twice with differnt
layout. How could this happen if I use standard include files?

Could somebody help? At the moment, managed C++ makes no sense at all to me.

regards,
Achim
ismailp - 22 May 2005 21:19 GMT
Will this class library contain unmanaged code as well? If so, please
read mixed mode DLLs on MSDN.

Normally, you wouldn't get an error for new operator. I don't remember
I have faced with a link failure with new operator.

For the second problem, move windows.h into precompiled header file, or
above the "#include <vfw.h>" line. It shouldn't be related to
meta-data.

What version of MC++ do you use?

Ismail
Achim Domma (Procoders) - 23 May 2005 05:32 GMT
> Will this class library contain unmanaged code as well? If so, please
> read mixed mode DLLs on MSDN.

Yes, it will contain unmanaged code. I have read the article on MSDN and
I think I understood the problem.

> Normally, you wouldn't get an error for new operator. I don't remember
> I have faced with a link failure with new operator.

I changed my code to use Windows functions to alloc/free memory. So
operator new is no problem at the moment.

> For the second problem, move windows.h into precompiled header file, or
> above the "#include <vfw.h>" line. It shouldn't be related to
> meta-data.

I moved both files to stdafx.h and it works now. Still don't understand
what the problem is. Do you know any good books about managed C++?

> What version of MC++ do you use?

I use the version which is part of Visual Studio 2003.

Thanks for your fast answer.

regards,
Achim
Ioannis Vranos - 23 May 2005 07:23 GMT
> I changed my code to use Windows functions to alloc/free memory. So
> operator new is no problem at the moment.

When using new for unmanaged types there should be no problem. Managed code and unmanaged
code are two separate worlds.

> I moved both files to stdafx.h and it works now. Still don't understand
> what the problem is. Do you know any good books about managed C++?

A good book is "Visual C++ .NET How To Program" by Deitel:

http://vig.prenhall.com/catalog/academic/product/0,1144,0134373774,00.html
ismailp - 23 May 2005 08:15 GMT
I have never encountered with such a problem with new/delete operators
before.

Having Windows.h at precompiled header or prior to other includes is
"must" for some header files those do not include windows.h themselves.
therefore, you need to include this before those headers in the
translation unit. the best way is putting it into precompiled header.

I think I have seen one book, it is MS-Press' but I couldn't recall its
name. Please try to focus on C++/CLI rather than MC++. MC++ will be
deprecated by C++/CLI.

Ismail
Achim Domma (Procoders) - 23 May 2005 08:40 GMT
> Having Windows.h at precompiled header or prior to other includes is
> "must" for some header files those do not include windows.h themselves.
> therefore, you need to include this before those headers in the
> translation unit. the best way is putting it into precompiled header.

I know that Vfw.h needs windows.h to be include first, so I had included
windows.h already. But I included both files in two different cpp files,
which seems to have caused the problem. Moving the includes to stdafx.h
works fine.

> I think I have seen one book, it is MS-Press' but I couldn't recall its
> name.

"Programming with Managed Extensions for Microsoft Visual C++ .NET
Version 2003" by Richard Grimes looks promissing but is quite expensive.

> Please try to focus on C++/CLI rather than MC++. MC++ will be
> deprecated by C++/CLI.

Don't know what you mean with C++/CLI and MC++ and what the difference
is!? Is MC++ 'classic' C++ with raw pointers, STL and so on and C++/CLI
is using the .Net framework?
If that's true, I would not give up MC++, because I realy like STL,
templates and so on. I implement low level algorithms and numeric stuff,
which I would like to make available to other .Net languages.

Currently I try to write a library to work with AVI Files. As already
mentioned, I use the Windows Multimedia SDK to read the AVI Files. I
have only seen C# interop examples which work with this API. An managing
raw memory in C# seems to be a pain to me.

How would you work with such raw C APIs?

regards,
Achim
Ioannis Vranos - 23 May 2005 12:42 GMT
> Don't know what you mean with C++/CLI and MC++ and what the difference
> is!? Is MC++ 'classic' C++ with raw pointers, STL and so on and C++/CLI
> is using the .Net framework?

C++/CLI is the descendant of "managed extensions" and will "replace and extend" them in VS
2005.

With VS 2005, C++ becomes the systems programming language of .NET.

Some references:

http://msdn.microsoft.com/msdnmag/issues/05/01/COptimizations/default.aspx

http://pluralsight.com/blogs/hsutter/archive/2004/10/05/2672.aspx

http://blogs.msdn.com/branbray/archive/2003/11/07/51007.aspx

http://www.accu.org/conference/presentations/Sutter_-_Is_C++_Relevant_on_Modern_
Environments_%28keynote%29.pdf


And a page of mine:

http://www23.brinkster.com/noicys/cppcli.htm

> If that's true, I would not give up MC++, because I realy like STL,
> templates and so on. I implement low level algorithms and numeric stuff,
> which I would like to make available to other .Net languages.

VS 2005 will also provide an STL version that will also work for managed types.
Ioannis Vranos - 29 May 2005 19:30 GMT
> C++/CLI is the descendant of "managed extensions" and will "replace and
> extend" them in VS 2005.

In other words, we can say that it is "managed extensions version 2". Even the draft
standard follows this as version numbering.

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.