473,545 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2286
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
1392
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 would hate to make web pages that can not be viewed by customers using these mediums as most people who use computers in a more entertainment light use...
6
2188
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 Namespace on new projects. Thus far I have been unable to find this information, please inform me. For example in the Visual Basic Namespace there are...
6
1664
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 changing an interface it breaks compatability, forcing all of my consuming assemblies to need recompiling. I know this could be done with VB6, what...
0
1113
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 . what r the ways to achieve the forward compatability for 1.1 developed applications ? i know we can use the <strartup><supportedruntime> in the...
1
1759
by: abbu | last post by:
Hi, Can anybody explain the difference between standard and compatability mode compilatin in C++? Regards, abbu
4
1865
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 are binary compatable ( i.e interfaces have not changed) then we can retain the same version number for the assembly and just change the hot fix...
1
3696
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 compatible with this version of SQL server" error. We put the server into SQL 2000 compatability mode, and things worked.
24
2440
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
2161
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 back end. I've heard that it's possible that the version of Office we are buying may have compatability issues with Access 2003. I find this hard...
0
7468
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7401
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7656
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
5972
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
4945
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.