473,398 Members | 2,335 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,398 software developers and data experts.

C++/CLI experiments

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
Nov 17 '05 #1
34 1575
> 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.

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
Nov 17 '05 #2
> 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.

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
Nov 17 '05 #3
Ioannis,
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?


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....
--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #4
Ioannis,
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?


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....
--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #5
Don Kim wrote:
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/d...displaylang=en

The changes below made it compile:

#using <mscorlib.dll>

int main()
{
using namespace System;

String ^s = "Hello world";

Console::WriteLine(s);

}


mscorlib.dll is not required in C++/CLI standard.


Best regards,

Ioannis Vranos
Nov 17 '05 #6
Don Kim wrote:
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/d...displaylang=en

The changes below made it compile:

#using <mscorlib.dll>

int main()
{
using namespace System;

String ^s = "Hello world";

Console::WriteLine(s);

}


mscorlib.dll is not required in C++/CLI standard.


Best regards,

Ioannis Vranos
Nov 17 '05 #7
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
Nov 17 '05 #8
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
Nov 17 '05 #9
Ioannis Vranos wrote:
Feel free to report it yourself. :-)

I changed my mind. I will report it now to have the fun. :-)


Best regards,

Ioannis Vranos
Nov 17 '05 #10
Ioannis Vranos wrote:
Feel free to report it yourself. :-)

I changed my mind. I will report it now to have the fun. :-)


Best regards,

Ioannis Vranos
Nov 17 '05 #11
Ioannis Vranos wrote:
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
Nov 17 '05 #12
Ioannis Vranos wrote:
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
Nov 17 '05 #13
Ioannis Vranos wrote:
"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
Nov 17 '05 #14
Ioannis Vranos wrote:
"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
Nov 17 '05 #15
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
Nov 17 '05 #16
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
Nov 17 '05 #17
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.
Nov 17 '05 #18
"Gabest" <ga****@freemail.hu> wrote in message
news:OC**************@TK2MSFTNGP15.phx.gbl...
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
Nov 17 '05 #19
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 :). 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.


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...

--
Tomas Restrepo
to****@mvps.org
Nov 17 '05 #20
Gabest wrote:
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#
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.

The truth is... C++/CLI will be better than current C#.


Best regards,

Ioannis Vranos
Nov 17 '05 #21
William DePalo [MVP VC++] wrote:

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++.


I am sorry to disappoint you but you are wrong. Check these:
http://microsoft.sitestream.com/Tech...V333_Sutte.ppt
http://www.accu.org/conference/prese...keynote%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
Nov 17 '05 #22
Ioannis Vranos wrote:

I am sorry to disappoint you but you are wrong. Check these:
http://microsoft.sitestream.com/Tech...V333_Sutte.ppt

http://www.accu.org/conference/prese...keynote%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.

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
Nov 17 '05 #23
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.

"Ioannis Vranos" <iv*@guesswh.at.grad.com> wrote in message
news:OU****************@TK2MSFTNGP12.phx.gbl...
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

Nov 17 '05 #24
>> 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++? :)
Nov 17 '05 #25
> 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.
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.

--
Tomas Restrepo
to****@mvps.org

Nov 17 '05 #26
>> 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 :)
Nov 17 '05 #27
"Ioannis Vranos" <iv*@guesswh.at.grad.com> wrote in message
news:ug**************@TK2MSFTNGP09.phx.gbl...
I am sorry to disappoint you but you are wrong.
:-)

Check these:
http://microsoft.sitestream.com/Tech...V333_Sutte.ppt
http://www.accu.org/conference/prese...keynote%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
Nov 17 '05 #28
William DePalo [MVP VC++] wrote:
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.

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
Nov 17 '05 #29
Gabest wrote:
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 :)

Those were my questions/doubts about specific features of C++/CLI. Check
this:

http://www23.brinkster.com/noicys/cppcli.htm


Best regards,

Ioannis Vranos
Nov 17 '05 #30
Hasani (remove nospam from address) wrote:
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.
int main()
{
using namespace System;

String s="Hello world";

Console::WriteLine(%s);

}


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
Nov 17 '05 #31
> 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.


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
Nov 17 '05 #32
> Did you install Visual C++tools refresh (for Beta 1)?

http://www.microsoft.com/downloads/d...displaylang=en


Yes, after installing the above, I got the exact same result as you.
Thanks.

- Don Kim
Nov 17 '05 #33
Don Kim wrote:
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.

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,

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
Nov 17 '05 #34
"Don Kim" <de*******@nospam.donkim.info> wrote in message
news:jO*****************@newssvr27.news.prodigy.co m...
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
Nov 17 '05 #35

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

Similar topics

3
by: Alex Bell | last post by:
I am still trying to design a two column layout but neither http://www.tassie.net.au/~abell1/meyer332.htm nor http://www.tassie.net.au/~abell1/testmenu1.htm work as they should Could some kind...
40
by: Greg G | last post by:
http://risky-biz.com/new/risky.html I finally got DSL service recently, but I haven't forgotten the agony of waiting for the 64th image to load before I can see ANYTHING on a page. So I will...
7
by: cjl | last post by:
OK: I am really scratching my head over a preload / image swapping problem, so I started conducting experiments: http://www.saintrays.net/experiment1.html...
8
by: Steve Zimmerman | last post by:
This post is not intended as an argument to any other post, just some simple scanf experiments that I wanted to share. I found experiments 5 and 6 the most educational. Also, I thought...
2
by: Steve Zimmerman | last post by:
Esteemed contributors to clc: Thank you for all the responses. Experiments 2 and 3 below are identical, except that experiment 2 does not call free(), while experiment 3 does. With such a...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
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,...

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.