.NET Forum / Languages / Managed C++ / September 2004
C++/CLI experiments
|
|
Thread rating:  |
Ioannis Vranos - 30 Aug 2004 23:21 GMT OK, I just installed the tools refresh in VC++ 2005 Express Beta1, and now it can indeed be called a Beta.
I decided to check the ref types on stack thing, and after some seconds of effort I came to this:
int main() { using namespace System;
String s="Hello world";
Console::WriteLine(%s);
}
C:\c>cl /clr:safe temp.cpp Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40809 for Microsoft (R) .NET Framework version 2.00.40607.16 Copyright (C) Microsoft Corporation. All rights reserved.
temp.cpp Microsoft (R) Incremental Linker Version 8.00.40809 Copyright (C) Microsoft Corporation. All rights reserved.
/out:temp.exe temp.obj
C:\c>temp
C:\c>
==> It doesn't print "Hello world".
Questions on the above:
The String object created above is equivalent to new String("Hello World")?
Why it doesn't print anything?
Best regards,
Ioannis Vranos
Tomas Restrepo \(MVP\) - 31 Aug 2004 01:09 GMT Ioannis,
> OK, I just installed the tools refresh in VC++ 2005 Express Beta1, and > now it can indeed be called a Beta. [quoted text clipped - 35 lines] > > Why it doesn't print anything? Ouch! Looks like a compiler bug, to me. Looking at the generated code, one can see the compiler is loading s with null, not with the reference to the string :(
You might want to report that....
 Signature Tomas Restrepo tomasr@mvps.org
Ioannis Vranos - 31 Aug 2004 01:23 GMT Tomas Restrepo (MVP) wrote:
> Ouch! Looks like a compiler bug, to me. Looking at the generated code, one > can see the compiler is loading s with null, not with the reference to the > string :( > > You might want to report that.... Feel free to report it yourself. :-)
Best regards,
Ioannis Vranos
Ioannis Vranos - 31 Aug 2004 01:26 GMT > Feel free to report it yourself. :-) I changed my mind. I will report it now to have the fun. :-)
Best regards,
Ioannis Vranos
Ioannis Vranos - 31 Aug 2004 01:32 GMT > I changed my mind. I will report it now to have the fun. :-) "Error
An error has occurred during the processing of your request. Please try again later."
Now this is funny, isn't it?
Best regards,
Ioannis Vranos
Ioannis Vranos - 31 Aug 2004 01:38 GMT > "Error > > An error has occurred during the processing of your request. Please try > again later." OK, now that I resubmitted it with IE it worked. :-)
Best regards,
Ioannis Vranos
Ioannis Vranos - 31 Aug 2004 01:56 GMT Tomas Restrepo (MVP) wrote:
> Ouch! Looks like a compiler bug, to me. Looking at the generated code, one > can see the compiler is loading s with null, not with the reference to the > string :( > > You might want to report that.... I submitted it under the subject "String initialisation bug".
Best regards,
Ioannis Vranos
Don Kim - 31 Aug 2004 01:10 GMT > int main() > { [quoted text clipped - 16 lines] > > Why it doesn't print anything? Wierd, when I tried to compile the above, the compler complained I could not allocate the String on the stack. I had to reference with ^.
The changes below made it compile:
#using <mscorlib.dll>
int main() { using namespace System;
String ^s = "Hello world";
Console::WriteLine(s);
}
- Don Kim
Ioannis Vranos - 31 Aug 2004 01:22 GMT > Wierd, when I tried to compile the above, the compler complained I could not > allocate the String on the stack. Did you install Visual C++tools refresh (for Beta 1)?
http://www.microsoft.com/downloads/details.aspx?familyid=afd04ff1-9d16-439a-9a5e -e13eb0341923&displaylang=en
> The changes below made it compile: > [quoted text clipped - 9 lines] > > } mscorlib.dll is not required in C++/CLI standard.
Best regards,
Ioannis Vranos
Don Kim - 01 Sep 2004 00:26 GMT > Did you install Visual C++tools refresh (for Beta 1)? > > http://www.microsoft.com/downloads/details.aspx?familyid=afd04ff1-9d16-439a-9a5e -e13eb0341923&displaylang=en Yes, after installing the above, I got the exact same result as you. Thanks.
- Don Kim
Gabest - 31 Aug 2004 02:37 GMT After having read several posts involving Ioannis Vranos' experiments with the new syntax, questions raised inside me (forgive me, it's 3:29am now :). Is transforming C++ to a new - "alien" looking - language necessary? Wasn't C# supposed to be THE new language? In the end by how much will MC++ and C# differ really? Because I have the feeling they won't too much, since they are going to compile to the same code in the end, and this drives developers of the languages towards similar design goals. Allowing many languages used is nice idea but without having hands tied by some nasty c++ standards the differencies between these two languages can fade away quickly. This is only my opinion of course.
William DePalo [MVP VC++] - 31 Aug 2004 02:51 GMT > After having read several posts involving Ioannis Vranos' experiments with > the new syntax, questions raised inside me (forgive me, it's 3:29am now > :). Is transforming C++ to a new - "alien" looking - language necessary? IMO, that question begs another question. Is it important to you to be able to target the .Net platform using a language a lot like, but not the same as, ISO C++?
If your answer is "No" then C# is the way to go. If it is "Yes" then, again IMO, you need to accept the departures from the bog standard language in order to accomodate .Net concepts like garbage collection on which the language is silent.
> Wasn't C# supposed to be THE new language? Umm, Yes. And it is.
> In the end by how much will MC++ and C# differ really? A lot. C# is elegant and expressive and values those attributes far more over some level of compatibilty with an existing language. This compatibility, is either a huge complication or a absolute necessity. :-) It all depends on how much you value the tie to C++.
> This is only my opinion of course. As all of the above is mine.
Regards, Will
Ioannis Vranos - 31 Aug 2004 13:09 GMT >>Wasn't C# supposed to be THE new language? > [quoted text clipped - 6 lines] > compatibility, is either a huge complication or a absolute necessity. :-) It > all depends on how much you value the tie to C++. I am sorry to disappoint you but you are wrong. Check these:
http://microsoft.sitestream.com/TechEd/DEV/DEV333_files/Botto_files/DEV333_Sutte.ppt
http://www.accu.org/conference/presentations/Sutter_-_Is_C++_Relevant_on_Modern_ Environments_%28keynote%29.pdf
Read that C++/CLI is usually 25% faster than C# for pure .NET code and that C++/CLI is correct by default while C# correct by explicit coding.
I may mutter about some details from time to time, but the truth is I like C++/CLI very much.
Best regards,
Ioannis Vranos
Ioannis Vranos - 31 Aug 2004 13:17 GMT > I am sorry to disappoint you but you are wrong. Check these: > [quoted text clipped - 7 lines] > I may mutter about some details from time to time, but the truth is I > like C++/CLI very much. And to make the above more clear, C++/CLI will be more powerful than C#. Except of the low level IL stuff and the language stuff like templates used with managed types and generics used in combination with templates that will not be able with C#, there are heavy optimisations from the compiler including the upcoming POGO optimisation available only for C++ .NET programs.
Best regards,
Ioannis Vranos
William DePalo [MVP VC++] - 31 Aug 2004 16:38 GMT > I am sorry to disappoint you but you are wrong.
:-)
> Check these: > > http://microsoft.sitestream.com/TechEd/DEV/DEV333_files/Botto_files/DEV333_Sutte.ppt > > http://www.accu.org/conference/presentations/Sutter_-_Is_C++_Relevant_on_Modern_ Environments_%28keynote%29.pdf Yup. Seen 'em, read 'em.
As I see it the problem with C++ is that it sets the bar to entry way above the skillsets of those who call themselves "developers" these days, some of whom should be selling shoes. <BSEG>
C# IS THE mainstream .Net language.
C++/CLI WILL BE the .Net language used by the cognoscienti. We will continue to be the minority.
Regards, Will
Ioannis Vranos - 31 Aug 2004 19:18 GMT > Yup. Seen 'em, read 'em. > [quoted text clipped - 6 lines] > C++/CLI WILL BE the .Net language used by the cognoscienti. We will continue > to be the minority. Yes, C# will continue to be a minority, but don't get disappointed. I think that some of the C++/CLI stuff will eventually make into C#, while the most important thing, to create simple hello world applications in .NET, will continue to be feasible with C#.
Best regards,
Ioannis Vranos
Don Kim - 01 Sep 2004 00:26 GMT > As I see it the problem with C++ is that it sets the bar to entry way > above the skillsets of those who call themselves "developers" these days, [quoted text clipped - 4 lines] > C++/CLI WILL BE the .Net language used by the cognoscienti. We will > continue to be the minority. I think you are correct abou this, but I got to at least hand it to Microsoft for realizing that C++ programers were important, and putting in all the resources to get a much better C++ to CLI binding. Though initially I thought they were going to try and push everyone to C#, like Sun tired (and rather arrogantly so) to get everyone to go java.
Anyway, C++ was never the language for the masses, but Visual Basic was too light as well. C# does occupy a good middle ground, though I would prefer a language like Python for these kinds of tasks.
Still, I hope there are a lot of opportunities with C++/CLI because I happen to really like it.
- Don Kim
Ioannis Vranos - 01 Sep 2004 01:55 GMT >>As I see it the problem with C++ is that it sets the bar to entry way >>above the skillsets of those who call themselves "developers" these days, [quoted text clipped - 12 lines] > > Anyway, C++ was never the language for the masses, I do not know if you know it, but C++ has been more widespread than VB, Java and C# all these years.
Best regards,
Ioannis Vranos
William DePalo [MVP VC++] - 01 Sep 2004 03:12 GMT > Still, I hope there are a lot of opportunities with C++/CLI because I > happen to really like it. Ditto to both sentiments. :-)
Regards, Will
Gabest - 31 Aug 2004 16:18 GMT >> Wasn't C# supposed to be THE new language? > > Umm, Yes. And it is. ... and how long can it live, next to the almighty managed c++? :)
Tomas Restrepo \(MVP\) - 31 Aug 2004 03:01 GMT Gabest,
> After having read several posts involving Ioannis Vranos' experiments with > the new syntax, questions raised inside me (forgive me, it's 3:29am now [quoted text clipped - 7 lines] > differencies between these two languages can fade away quickly. This is only > my opinion of course. I'll leave MS to answer this fully, but having done quite a bit of work with the existing MC++ myself, I can say that C++/CLI is a step in the right direction. The syntax is far more natural and far more powerful. C# might be nice, but when it comes to raw power, it doesn't even come close to what C++/CLI will offer, since it allows you access to almost all the features that can be represented in metadata.
Also, it allows both templates and generics (even templates over ref classes), which goes far beyond just the generics support in C#.
If you haven't already, I'd strongly suggest reading both the C++/CLI migration guide I referenced in an earlier message, as well as all the blog entries by Brandon Bray !(http://blogs.msdn.com/branbray) and Herb Sutter (http://blogs.msdn.com/hsutter/).... they do a great job of explaining the rationale for the new syntax...
 Signature Tomas Restrepo tomasr@mvps.org
Gabest - 31 Aug 2004 16:22 GMT > I'll leave MS to answer this fully, but having done quite a bit of work > with [quoted text clipped - 4 lines] > C++/CLI will offer, since it allows you access to almost all the features > that can be represented in metadata. I'm sure it goes to the right direction, just wondered why it wasn't C# going to that direction instead.
> Also, it allows both templates and generics (even templates over ref > classes), which goes far beyond just the generics support in C#. Yea, having templates is a big plus over C. For example not being able to have type safe collection classes was my biggest complain about C# (also true for delphi and java).
> If you haven't already, I'd strongly suggest reading both the C++/CLI > migration guide I referenced in an earlier message, as well as all the > blog > entries by Brandon Bray !(http://blogs.msdn.com/branbray) and Herb Sutter > (http://blogs.msdn.com/hsutter/).... they do a great job of explaining the > rationale for the new syntax... Thanks, I will. Though I don't have too much time to closely follow everything but I'm very interested and always try read every topic about it in this newsgroup.
Ioannis Vranos - 31 Aug 2004 13:04 GMT > After having read several posts involving Ioannis Vranos' experiments with > the new syntax, Where?
> questions raised inside me (forgive me, it's 3:29am now :). > Is transforming C++ to a new - "alien" looking - language necessary? No.
> Wasn't > C# supposed to be THE new language? In the end by how much will MC++ and C# [quoted text clipped - 4 lines] > differencies between these two languages can fade away quickly. This is only > my opinion of course. The truth is... C++/CLI will be better than current C#.
Best regards,
Ioannis Vranos
Gabest - 31 Aug 2004 16:22 GMT >> After having read several posts involving Ioannis Vranos' experiments >> with the new syntax, > > Where? "Handle to pointer conversion" "VC++ 2005 and ref objects in the stack" .. and this one :)
Ioannis Vranos - 31 Aug 2004 19:20 GMT >>>After having read several posts involving Ioannis Vranos' experiments >>>with the new syntax, [quoted text clipped - 4 lines] > "VC++ 2005 and ref objects in the stack" > .. and this one :) Those were my questions/doubts about specific features of C++/CLI. Check this:
http://www23.brinkster.com/noicys/cppcli.htm
Best regards,
Ioannis Vranos
Hasani \(remove nospam from address\) - 31 Aug 2004 14:46 GMT Have you tried being more explicit in your declaration and see if that works?
e.x.: System::String str = S"Hello World";
Not that what you have already shouldn't work.
> OK, I just installed the tools refresh in VC++ 2005 Express Beta1, and now > it can indeed be called a Beta. [quoted text clipped - 40 lines] > > Ioannis Vranos Ioannis Vranos - 31 Aug 2004 19:23 GMT Hasani (remove nospam from address) wrote:
> Have you tried being more explicit in your declaration and see if that > works? [quoted text clipped - 12 lines] >> >>} No, you are wrong. But I will give you the compiler messages to understand:
int main() { using namespace System;
String s=S"Hello world";
Console::WriteLine(%s); }
C:\c>cl /clr:safe temp.cpp Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40809 for Microsoft (R) .NET Framework version 2.00.40607.16 Copyright (C) Microsoft Corporation. All rights reserved.
temp.cpp temp.cpp(5) : error C3921: Use of S-prefixed strings requires /clr:oldSyntax command line option
When compiling with /clr, an implicit conversion exists from string literal type to System::String^. If necessary to avoid ambiguity, cast to System::String^
C:\c>
Best regards,
Ioannis Vranos
Free MagazinesGet 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 ...
|
|
|