developing managed c++ library

  • Thread starter Achim Domma (Procoders)
  • Start date
A

Achim Domma (Procoders)

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
 
I

ismailp

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
 
A

Achim Domma (Procoders)

ismailp said:
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
 
I

Ioannis Vranos

Achim said:
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
 
I

ismailp

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
 
A

Achim Domma (Procoders)

ismailp said:
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
 
I

Ioannis Vranos

Achim said:
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/pres...Relevant_on_Modern_Environments_(keynote).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.
 
I

Ioannis Vranos

Ioannis said:
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.
 

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