By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,948 Members | 664 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,948 IT Pros & Developers. It's quick & easy.

C++/CLI only way to use C++ for .NET?

P: n/a
Hi,

I am working on a small fun programming project (AntMe if anyone knows
it) which provides code examples for C# and Visual Basic 2005

After doing some programming with C#, I was going to try to write a
library for it with C++ too.
I never worked with .NET before only with plain C++ so I tried to find
some information about it. The only thing I found on the net are
references to Managed C++ and its successor C++/CLI.

Did I interpret the information I found on the net correctly that there
is no way to programm a .NET compatible assembly without the CLI syntax
extensions (or said in a different way, just by using only the C++
standard language)?
If so that confuses me a little since I've also found various sources
stating that C++ was a .NET compatible language. But from my knowledge
C++ and C++/CLI are not the same language but have some fundamental
differences.

Any information or a good link about this topic (Just googling for
C++/CLI and .NET didn't help much, too many (and unhelpful) results)
would be appreciated

Thanks
Apr 18 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Andreas Schmitt wrote:
Hi,

I am working on a small fun programming project (AntMe if anyone knows
it) which provides code examples for C# and Visual Basic 2005

After doing some programming with C#, I was going to try to write a
library for it with C++ too.
I never worked with .NET before only with plain C++ so I tried to find
some information about it. The only thing I found on the net are
references to Managed C++ and its successor C++/CLI.

Did I interpret the information I found on the net correctly that there
is no way to programm a .NET compatible assembly without the CLI syntax
extensions (or said in a different way, just by using only the C++
standard language)?
If so that confuses me a little since I've also found various sources
stating that C++ was a .NET compatible language. But from my knowledge
C++ and C++/CLI are not the same language but have some fundamental
differences.

Any information or a good link about this topic (Just googling for
C++/CLI and .NET didn't help much, too many (and unhelpful) results)
would be appreciated
Andreas:

In VS2005 you must use C++/CLI to target the .NET framework. You cannot
do it with standard C++.

--
David Wilkinson
Visual C++ MVP
Apr 18 '07 #2

P: n/a
I am working on a small fun programming project (AntMe if anyone knows
it) which provides code examples for C# and Visual Basic 2005

After doing some programming with C#, I was going to try to write a
library for it with C++ too.
I never worked with .NET before only with plain C++ so I tried to find
some information about it. The only thing I found on the net are
references to Managed C++ and its successor C++/CLI.

Did I interpret the information I found on the net correctly that there
is no way to programm a .NET compatible assembly without the CLI syntax
extensions (or said in a different way, just by using only the C++
standard language)?
If so that confuses me a little since I've also found various sources
stating that C++ was a .NET compatible language. But from my knowledge
C++ and C++/CLI are not the same language but have some fundamental
differences.

Any information or a good link about this topic (Just googling for
C++/CLI and .NET didn't help much, too many (and unhelpful) results)
would be appreciated
Hi,

C++/CLI is a superset of C++, just like C++ itself is a superset of C.
C++ is still a native only language. C++/CLI allows you to write .NET apps,
as well as apps that mixe native code and .NET code in the same module.

Managed C++ is the predecessor to C++/CLI. It is dead -rightfully so I might
add- and will be all but a bad dream in the near future.

There is an interesting rationale behind a lot of the C++/CLI design
decisions that can be found here: www.gotw.ca/publications/C++CLIRationale.pdf
It is written by Herb Sutter, the main man behind the C++ front end.

--
Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Apr 19 '07 #3

P: n/a
Any information or a good link about this topic (Just googling for C++/CLI
and .NET didn't help much, too many (and unhelpful) results) would be
appreciated
..NET assemblies carry metadata that is required for other .NET languages to
use the types and functions inside. This metadata is created only when the
C++/CLI extended syntax is used. For example, .NET requires every type to
be marked as either pass-by-value (stack and embedded variables) or
pass-by-reference (garbage collected), and native C++ syntax doesn't
indicate to the compiler which you desire.

So:
(1) The only C++ compiler capable of writing out a .NET assembly is
currently MS Visual C++ using the /clr format.
(2) /clr works with ISO standard C++ programs (commonly called native C++)
to produce .NET assembly files, but these will be missing the metadata, so
the .NET assembly cannot be usefully referenced by any other .NET program
(even C++).
(3) Using C++/CLI keywords such as "ref class" provides the compiler with
the additional information needed to produce the metadata. It also subjects
those parts of your code to the additional constraints placed on .NET types
(single inheritance, for instance).
Apr 19 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.