473,411 Members | 1,980 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,411 software developers and data experts.

PtrToStringChars in Vc7/include/vcclr.h

In the header file vcclr.h (in the .../Vc7/include directory of your
installation) there is an inlined function PtrToStringChars defined. This
is a utility function to get quick access to the internal chars of a
System::String object. I came across it by reading Peter Grimes's "Managed
Extensions for Visual C++.NET" published by MSPress.

In any case, its implementation makes no sense to me. The line that sets
offset calls the property OffsetToStringData on a static class called
RuntimeHelpers in the System::Runtime::CompilerServices namespace.

Strangely, there is no reference in this call to the property to the
underlying string, and yet the MSIL produces clearly shows that the String
reference is passed as the parameter to the get_OffsetToStringData method.
The syntax though in the c++ code does not indicate this in any way.

Clearly something strange is going on here. Does anyone have an
explanation? Is the compiler producing weird code because this is something
from the CompilerServices namespace, or do I not understand something about
managed c++ properties (very possible, I'm new to managed c++).

Very curious to understand what is going on. Thanks,

-Eric
Nov 16 '05 #1
2 4559
Eric,
Strangely, there is no reference in this call to the property to the
underlying string,
There doesn't have to be, the offset is the same regardless of the
string.

and yet the MSIL produces clearly shows that the String
reference is passed as the parameter to the get_OffsetToStringData method.
The syntax though in the c++ code does not indicate this in any way.


Are you sure you're not misinterpreting the IL code?
get_OffsetToStringData takes no parameters.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2
Matthias,

Thanks for the quick response. That of course makes sense, the offset would
be the same regardless of the String object instance. I was not
interpreting the MSIL correctly, as you surmised. Thanks for the
clarification.

-Eric

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OJ**************@TK2MSFTNGP11.phx.gbl...
Eric,
Strangely, there is no reference in this call to the property to the
underlying string,


There doesn't have to be, the offset is the same regardless of the
string.

and yet the MSIL produces clearly shows that the String
reference is passed as the parameter to the get_OffsetToStringData method.The syntax though in the c++ code does not indicate this in any way.


Are you sure you're not misinterpreting the IL code?
get_OffsetToStringData takes no parameters.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Nov 16 '05 #3

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

Similar topics

43
by: steve | last post by:
I am quite frustrated with php’s include, as I have spent a ton of time on it already... anyone can tell me why it was designed like this (or something I don’t get)? The path in include is...
60
by: Derrick Coetzee | last post by:
It seems like, in every C source file I've ever seen, there has been a very definite include order, as follows: - include system headers - include application headers - include the header...
9
by: zolli | last post by:
Hi, I've been banging my head against this for a while now. Hoping someone here can shed some light on what's going on. On including stdlib.h in a file, I'm seeing the following errors: ...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
9
by: cppdev | last post by:
What should happen if String contents are changed like below? The contents do change and nothing crashed or anything. String* str = S"hello"; Char __pin* ps =...
1
by: ya man | last post by:
when i use #include <iostream.h> in some files i get lots of error messages of the kind 'ambiguous symbol this is solved when i use #include <iostream why is that ? and can i use #include...
2
by: Tommy Vercetti | last post by:
I'm new to Managed C++ development, and I can't seem to get started. Every time I try to include vcclr.h I get bizarre compilation errors. I've isolated this to a really simple case: In Visual...
3
by: Arpi Jakab | last post by:
I have a main project that depends on projects A and B. The main project's additional include directories list is: ...\ProjectA\Dist\Include ...\ProjectB\Dist\Include Each of the include...
0
by: Madhu_TN | last post by:
Hi All, I am new to this board. I am trying to create a Crystal Report viewer into a VS C++ Dot NET 2003 app ( This uses both managed and unmanaged code). I get the following compilation error:...
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
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.