longs in managed C++

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is a long in managed c++ a 64-bit number like in C#
If so how can I distinguish between that and one that's in some unmanaged code, and therefore that is 32-bit
Call it an int
 
Songie,
Is a long in managed c++ a 64-bit number like in C#?
If so how can I distinguish between that and one that's in some unmanaged
code, and therefore that is 32-bit?
Call it an int?

What Ronald said. Notice you can use __int64 (both in managed and unmanaged
code) to handle 64-bit numbers (or System::Int64 for just managed code)
 
OK, being from MSFT maybe you'll know the answer to this.
What is the reason that a long in C# is 64-bits, while a long in
MC++ is 32-bits. Is it perhaps because it is predicted that C# is
the language of the future, while MC++ is there only to provide
IJW for those that feel the need to use it (for whatever reason),
and that we'll all be moving on to 64-bit processors soon anyway
so it makes sense to use a 64-bit variable?
 
songie said:
OK, being from MSFT maybe you'll know the answer to this.
What is the reason that a long in C# is 64-bits, while a long in
MC++ is 32-bits. Is it perhaps because it is predicted that C# is
the language of the future, while MC++ is there only to provide
IJW for those that feel the need to use it (for whatever reason),
and that we'll all be moving on to 64-bit processors soon anyway
so it makes sense to use a 64-bit variable?

I wouldn't presume to answer for Ronald, but my understanding is that
consideration of Win32/Win64 and other compatibility issues dictated int and
long remain 32 bits for the C++ compiler. It would be bad for Managed C++ to
define a larger size, because then you would throw IJW out the window. C#,
being a brand new language, had none of these concerns, but note that its
int type remains 32 bits, which is enough for most purposes. As in C++, your
primary integer data type in C# is int.

As for the future of C++ on .NET, not only is C++ not being back-burnered,
it's going to be much, much better in the next release. See this MSDN
article for more:

Write Faster Code with the Modern Language Features of Visual C++ 2005
http://msdn.microsoft.com/msdnmag/issues/04/05/VisualC2005/default.aspx

In some ways, such as the new support for deterministic finalization, it
will become superior to C#, and even viewed solely as a pure .NET language,
VC++ 2005 is looking very attractive.
 
And you can also use the somewhat more portable "long long".

Ronald
 
Hi Ronald,
And you can also use the somewhat more portable "long long".

Ahh true! I had forgotten it is now supported! :)

thanks!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top