473,396 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Visual C++ .NET compatability with Visual C++

I am completley new to the .NET framework but have
a good understanding of Visual C++.

I am starting to develop a new class libary which other
programmers can use in their applications. To do this in
Visual C++, I'll be creating a DLL with exported classes.

I would like to develop this class libary in Visual
C++ .NET but am concerned it won't be able to be used by
standard Visual C++ developers.

If I created a DLL in .NET which makes use of some of the
..NET framework classes, could it be used in Visual C++
(assuming the header file presented hides away the .NET
class stuff)?

Any help and advice much appreciated.

Tristan.
Nov 16 '05 #1
5 2277
Hi,

As far as I know, you can mix unmanaged and managed C++ code. Just make sure
you only export unmanaged data structures and class interfaces, and although
I'm not absolutely sure, I think you'll be fine.

Things that might come in handy: the __pin keyword, see
http://www.codeproject.com/managedcp...p?target=__pin for
more information

The gcroot<> template, see
http://www.codeproject.com/managedcp...=managed%7Cstl for
more information on using STL in managed classes

I hope this helps.

Regards,

Thijs

"Tristan Sehgal" <tr************@yahoo.co.uk> schreef in bericht
news:09****************************@phx.gbl...
I am completley new to the .NET framework but have
a good understanding of Visual C++.

I am starting to develop a new class libary which other
programmers can use in their applications. To do this in
Visual C++, I'll be creating a DLL with exported classes.

I would like to develop this class libary in Visual
C++ .NET but am concerned it won't be able to be used by
standard Visual C++ developers.

If I created a DLL in .NET which makes use of some of the
.NET framework classes, could it be used in Visual C++
(assuming the header file presented hides away the .NET
class stuff)?

Any help and advice much appreciated.

Tristan.

Nov 16 '05 #2
Tristan Sehgal wrote:
I am completley new to the .NET framework but have
a good understanding of Visual C++.

I am starting to develop a new class libary which other
programmers can use in their applications. To do this in
Visual C++, I'll be creating a DLL with exported classes.

I would like to develop this class libary in Visual
C++ .NET but am concerned it won't be able to be used by
standard Visual C++ developers.

If I created a DLL in .NET which makes use of some of the
.NET framework classes, could it be used in Visual C++
(assuming the header file presented hides away the .NET
class stuff)?


I'm going to take a leap and assume that by "Visual C++" you mean VC6. If
by "standard Visual C++" you mean Visual C++ .NET, but generating unmanaged
(native) code only, then you can ignore the rest of this post, and take the
short answer: yes.

Short answer: yes: You can build a DLL with Visual C++ .NET 2002 or 2003
that can be used by "standard Visual C++ developers".

Long answer: It sounds like what you're wanting to do is produce a DLL
that's usable by programmers using a different version of Visual C++. This
can be done, but you have to be careful about the interface you expose.
Mixing compiler versions exposes you to all the same sorts of problems as
mixing compiler brands (e.g. Borland compiled DLL used from a VC compiled
EXE), with the added twist that mixing versions usually makes the problems
more subtle and easier to overlook.

To produce a DLL that can be used from any C/C++ compiler that can target
Windows, you need to restrict your exposed interface to a pure 'C'
interface, with all resource management handled explicitly through your
exposed APIs.

You have to assume that:
- Object layout between the two compilers might be incompatible.
- C Runtime library resources, such as <stdio.h> file handles are not
sharable across the interface.
- C++ runtime library resources, such as <iostream> streams are not sharable
across the interface.
- Heap allocations have permanent affinity with their original allocator
(e.g. if it's allocated by the DLL, it must be freed by the DLL).
- C++ name mangling is incompatible between the two systems, so only 'extern
"C"' functions can be exposed.
- Library designs in general will be incompatible: you can't pass
std::string, or CString, or ATL::CStringT<> across the interface.

If you adhere to these guidelines, you can produce a DLL that can be used by
anyone.

-cd


Nov 16 '05 #3
Carl Daniel [VC++ MVP] wrote:
To produce a DLL that can be used from any C/C++ compiler that can
target Windows, you need to restrict your exposed interface to a pure
'C' interface, with all resource management handled explicitly
through your exposed APIs.


One other option I forgot to mention: You could expose your objects through
COM interfaces. If you expose only COM interface, and live by the COM rules
correctly, you can make a DLL that can be used from another version of VC++
or even another language entirely.

-cd
Nov 16 '05 #4

Thanks very much for your help.

Along the same lines, I was wondering if a .NET component
can be created from unmanaged C++ code so that it could
be used by other .NET developers? Would there be any point
in doing this?

Many thanks

Tristan.
Nov 16 '05 #5
Tristan Sehgal wrote:
Thanks very much for your help.

Along the same lines, I was wondering if a .NET component
can be created from unmanaged C++ code so that it could
be used by other .NET developers? Would there be any point
in doing this?


A managed component (.NET class) can be created from Managed C++, but not
from unmanaged C++. It's possible to create an unmanaged class that wraps a
managed class, providing an unmanaged interface to that .NET class. This
can be useful, for example, to use .NET classes to build a plug-in for an
existing, native application.

-cd
Nov 16 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: WStoreyII | last post by:
I know that the main two browsers are ie and netscape. However, how do i know if browsers like aol and other abstract browser put out by isps like sbc and earthlink are compatable with asp.net. I...
6
by: Chris Lane | last post by:
Hi, I have been searching for a possible list that shows what methods or properties in the System Names replace the ones in the Visual Basic Namespace so I can stop using the Visual Basic...
6
by: Nak | last post by:
Hi there, I was wondering if anyone knew of a way to maintain compatability with assemblies providing the interfaces remains the same? At the moment if I re-compile an assembly without actually...
0
by: SenthilVel | last post by:
hi I have my application built with Dotnet Framework 1.1 and now i can see most of clients having both the versions 2.0 and 1.1 in their systems, i get an issue when i run my 1.1 application . ...
1
by: abbu | last post by:
Hi, Can anybody explain the difference between standard and compatability mode compilatin in C++? Regards, abbu
4
by: zak | last post by:
we have a suite of products that have a number of shared assemblies. During development and support the shared assemblies code will change . I want to control the versioning, so if the code chnages...
1
by: jsmall | last post by:
Hi, We currently have a fairly old product, which was originally only compatible with SQL 2000. When we upgraded our server to SQL 2005, the client product gave us a "This product is not...
24
by: JJ | last post by:
I see the new software is 'RTM' but what does that mean in terms of when we can actually purchase it? Thanks, JJ
10
by: Bobby | last post by:
Hi, The organisation I work for is on the verge of buying Microsoft Office 2007 Pro Plus OLP NL. We currently use Office Pro 2003. Our business system is written in Access 2003 with a SQL Server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.