472,353 Members | 1,642 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,353 software developers and data experts.

Subject: "bool[] {byte[]}" reported as type in the locals window

In C#, I am calling a method implemented in Managed C++ that returns an array
of booleans. This method in turn calls unto unmanaged C++ code that returns
an unsigned byte array, which is implicitly casted to a bool __gc [].
However, in my client C# app, when I examine this array in the locals window,
it shows "bool[]" as the type of the array and "byte" as the type of each
element. If I try this in Whidbey beta, it shows "bool[] {byte[]}" and "bool
{byte}" as the types.

If I create an array of booleans in my C# program, I only see "bool" in the
name--no "bytes". Am I doing something wrong in treating a boolean array as
a byte array?

Thanks,
-- Chris
Nov 17 '05 #1
2 1295
Chris Wood wrote:
If I create an array of booleans in my C# program, I only see "bool" in
the name--no "bytes". Am I doing something wrong in treating a boolean
array as a byte array?


The statement "implicitly casted to a bool __gc []" is very suspicious.
Would you mind sharing an example that does this?

Because a "bool __nogc []" and "bool __gc []" are very different data
structures in C++, the only way to safely convert between them is to write
code that does so (i.e. write a for loop).

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.

Nov 17 '05 #2
Chris Wood wrote:
Everything appears to work fine when I do this, it's just that the
debugger displays the data type as "byte" for each element, rather than
"bool".


That's because the type is actually bool. The difference is between dynamic
type and static type. The dynamic type of an object never changes. Every
object is tagged so that the CLR (and thus the debugger) can tell what the
real type is.

This program demonstrates that idea:

#using <mscorlib.dll>
using namespace System;

bool ReadBools() __gc []
{
unsigned char buffer __gc [] = new unsigned char __gc [3];
return buffer;
}

int main() {
Object* o = ReadBools();
Console::WriteLine(o);
}

It's also worth noting that while the compiler is allowing the conversion,
it really shouldn't be doing that. The code is unverifiable.

--
Brandon Bray, Visual C++ Compiler http://blogs.msdn.com/branbray/
This posting is provided AS IS with no warranties, and confers no rights.

Nov 17 '05 #3

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

Similar topics

22
by: bq | last post by:
Hello, Two questions related to floating point support: What C compilers for the wintel (MS Windows + x86) platform are C99 compliant as far as...
3
by: Pablo Gutierrez | last post by:
I have a C# method that reads Binary data (BLOB type) from a database and returns the data an array of bytes (i.e byte outbyte = new byte;). The...
5
by: _BNC | last post by:
I've converted " byte" to "byte *" at times, using 'unsafe' and fixed { .... }, but the reverse does not seem to work. In this case, a C++ DLL...
3
by: Mochuelo | last post by:
Hi, In the constructor of a class, I am taking as a parameter the reference to a "bool", as in this code: ----------------------- public...
4
by: Frederick Gotham | last post by:
Does "bool" behave _exactly_ like any other integer type, except for when it comes to integer promotion? Consider the following C function whose...
2
by: abelniel | last post by:
Hi all, When I use "bool" type in my program, gcc pop an error error: `bool' undeclared (first use in this function) I have included the...
6
yabansu
by: yabansu | last post by:
Hi all, I think most of you probably know the two .NET framework functions, namely Encoding.GetBytes(string) and Encoding.GetString(byte), to...
3
by: knguyen | last post by:
Hello, I was trying to compile the source code from "Design Patterns: Elements of Reusable Object-Oriented Software", which can be obtained from...
2
by: Marcel Kloubert | last post by:
Hi! Example: public bool? IsChecked { get { throw new NotImplementedException(); } } What does the question mark after the bool mean...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.