473,880 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error C3699: '%' : cannot use this indirection on type 'System::String '

What's special about System::String?

For instance, why can't one write a function like

using System::String;
void foo( const String% );

or what's wrong with:

int main() {
String s = "Snoopy"; // or just String s; if the ctor is not synthesized
};

Also ADL does not seem to work reliably with String.

I can understand why delegates and arrays are special from a FE
perspective (even though, I strongly believe it's another design flaw), but
what the heck is special about System::String?

-hg
Nov 17 '05 #1
7 7849
System::String does not support stack semantics, so you cannot have a String
or a String%, you can have a String^ or a String^% though.

--
Regards,
Nish [VC++ MVP]
"Holger Grund" <hg@remove.ix-n.net> wrote in message
news:Of******** ******@TK2MSFTN GP12.phx.gbl...
What's special about System::String?

For instance, why can't one write a function like

using System::String;
void foo( const String% );

or what's wrong with:

int main() {
String s = "Snoopy"; // or just String s; if the ctor is not
synthesized
};

Also ADL does not seem to work reliably with String.

I can understand why delegates and arrays are special from a FE
perspective (even though, I strongly believe it's another design flaw),
but
what the heck is special about System::String?

-hg

Nov 17 '05 #2
"Nishant Sivakumar" <ni**@nospam.as ianetindia.com> wrote
System::String does not support stack semantics, so you cannot have a
String or a String%, you can have a String^ or a String^% though.

Yes, I see it is not. The question is why. I absolutely fail to understand
why one would design the language that way. For instance, why
can I write

ref class R{};
void foo( R% );
// or
void foo( System::Excepti on% );
int main()
{
R r;
System::Excepti on e;
}

-hg
Nov 17 '05 #3
Sorry Holger,

I should have read your poster better.

When I first encountered this, I was puzzled too. String is probably one of
the most frequently used BCL class and to exclude it from stack semantics
seemed weird to me.

Here's a quote from Kapil Khosla [MSFT]

<quote>To answer your question. System::String is immutable. It means that
you
cannot modify the object once created. All methods exposed by the String
class actually create a new object containing the modification.

Thus, it doesnt make a lot of sense to have String object on the stack as we
cannot create a destructor for the String class. For all types where we
support the stack semantics, we require that the type must have a destructor
or the compiler should be able to create one.

Hope it helps,
Kapil </quote>

It doesn't really make a lot of sense to me. The fact that String is
immutable or that it does not have a destructor should not really have
affected the design decision to exclude it from stack semantics - unless I
am missing something. Perhaps, someone in the VC++ team would throw some
light on this.

--
Regards,
Nish [VC++ MVP]
"Holger Grund" <hg@remove.ix-n.net> wrote in message
news:O5******** *****@TK2MSFTNG P15.phx.gbl...
"Nishant Sivakumar" <ni**@nospam.as ianetindia.com> wrote
System::String does not support stack semantics, so you cannot have a
String or a String%, you can have a String^ or a String^% though.

Yes, I see it is not. The question is why. I absolutely fail to understand
why one would design the language that way. For instance, why
can I write

ref class R{};
void foo( R% );
// or
void foo( System::Excepti on% );
int main()
{
R r;
System::Excepti on e;
}

-hg

Nov 17 '05 #4
"Nishant Sivakumar" <ni**@nospam.as ianetindia.com> wrote

When I first encountered this, I was puzzled too. String is probably one
of the most frequently used BCL class and to exclude it from stack
semantics seemed weird to me.

Here's a quote from Kapil Khosla [MSFT]

<quote>To answer your question. System::String is immutable. It means that
you
cannot modify the object once created. All methods exposed by the String
class actually create a new object containing the modification.
Oc, there are readonly instance methods and properties that do not
modify the string.
Thus, it doesnt make a lot of sense to have String object on the stack as
we
cannot create a destructor for the String class. For all types where we What's wrong with not creating a dtor or one that does nothing?
It doesn't really make a lot of sense to me. The fact that String is
immutable or that it does not have a destructor should not really have
affected the design decision to exclude it from stack semantics - unless I
am missing something. Perhaps, someone in the VC++ team would throw some
light on this.


Same here.

-hg
Nov 17 '05 #5
Holger Grund wrote:

I can understand why delegates and arrays are special from a FE
perspective (even though, I strongly believe it's another design
flaw), but what the heck is special about System::String?

Well, while you're at it, I'll appreciate if you could share your
understanding on the reasons for the limitations on arrays and delegates too
;-)

Arnaud
MVP - VC
Nov 17 '05 #6
"Arnaud Debaene" <ad******@clu b-internet.fr> wrote

I can understand why delegates and arrays are special from a FE
perspective (even though, I strongly believe it's another design
flaw), but what the heck is special about System::String?

Well, while you're at it, I'll appreciate if you could share your
understanding on the reasons for the limitations on arrays and delegates
too ;-)


I didn't say I like it ;-) But obviously, there's some compiler magic
involved
with arrays and delegates. For instance, the CLR doesn't expose arrays
as specialiazation s of ::cli::array<> as in C++/CLI. But there isn't
something
obviously different for String. IIRC it has a special short form at encoding
level and there are probably some subtleties involving string literal
conversions.

If you ask why a user should care about it, I don't know. In fact, I think
I filed a bug for the delegate case, which was closed as by design.

Yes, there it is:

http://lab.msdn.microsoft.com/Produc...d-f1595d7d7e45

-hg
Nov 17 '05 #7
Read your bug report. Is the essence of your concern that you can't pass
what I think is called a 'stack semantic' form of a delegate? That is, this
is ok:

delegate void void_func_ptr(v oid) ;

void myMethod( void_func_ptr^ f ) {}

but this is not:

void myMethod( void_func_ptr% f ) {}

Meaning, you can pass a 'void_func_ptr^ ' type but not a 'void_func_ptr% '
type? Then I can see your point, since it should be able to convert any '%'
type to a '^' type and go that way. Except, then this would not allow you to
overload these two calls differently (which could be the reason it's not
done, but what the heck do I know)...

My 2 cents...

[==P==]

"Holger Grund" <ho**********@r emove.ix-n.net> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
"Arnaud Debaene" <ad******@clu b-internet.fr> wrote

I can understand why delegates and arrays are special from a FE
perspective (even though, I strongly believe it's another design
flaw), but what the heck is special about System::String?

Well, while you're at it, I'll appreciate if you could share your
understanding on the reasons for the limitations on arrays and delegates
too ;-)


I didn't say I like it ;-) But obviously, there's some compiler magic
involved
with arrays and delegates. For instance, the CLR doesn't expose arrays
as specialiazation s of ::cli::array<> as in C++/CLI. But there isn't
something
obviously different for String. IIRC it has a special short form at
encoding
level and there are probably some subtleties involving string literal
conversions.

If you ask why a user should care about it, I don't know. In fact, I think
I filed a bug for the delegate case, which was closed as by design.

Yes, there it is:

http://lab.msdn.microsoft.com/Produc...d-f1595d7d7e45

-hg

Nov 17 '05 #8

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

Similar topics

0
1952
by: The Plankmeister | last post by:
Hi (again) I'm purposely generating an SQL error to test my aforementioned custom error handling function, but I encounter a strange problem. The error string generated by my forced error is: SQL error: Too few parameters. Expected 1., SQL state 07001 in SQLExecDirect Which is exactly what I expect. However, even if in my function I have no
27
51765
by: Trep | last post by:
Hi there! I've been having a lot of difficult trying to figure out a way to convert a terminated char array to a system::string for use in Visual C++ .NET 2003. This is necessary because I have some legcay C code that needs to process a string taken from a textbox, then I need to re-display the string as the textbox->Text. I easily found how to convert from system::string to char but I can't figure out how to go the other way!!
3
5664
by: Kendall Gifford | last post by:
Greetings. While trying to get a simple app working, I've been forced to delve into embedded and/or linked resources a bit. I read all the reference for the System.Resources namespace as well as all the material within the "Resources and Localization..." tutorial. While I'm confident I now know completely how to accomplish my original, simple task of embedding some icons into my assembly and use of the same at runtime, I realize I've a...
15
10847
by: Yifan | last post by:
Hi Does anybody know how to convert System::String* to char*? I searched the System::String class members and did not find any. Thanks Yifan
4
1841
by: Sparky Arbuckle | last post by:
I am looping through a listbox collection to build a SQL string that will be used to delete items from a database. I have tried many variances of the code below but have had no luck. The code below gives an error: Cast from type 'ListItem' to type 'String' is not valid. When i do a response.write(s) the item at the top row displays correctly. Here is the code I am using:
1
8278
by: Caroline | last post by:
I am trying to update a record though a stored procedure and parameters, but I keep getting this error: Additional information: Argument 'Prompt' cannot be converted to type 'String'. Any ideas? Here is the code
2
2193
by: XML newbie: Urgent pls help! | last post by:
Hi, I am getting the error: Value of type 'String' cannot be converted to '1-dimensional array of Long'. in the following line for TextBox2.Text field : doc.LoadXml(EDP.ExportPositions(TextBox1.Text, cmbStartDateandTime.SelectedText, cmbEndDateandTime.SelectedText, TextBox2.Text)))
0
1338
by: XML newbie: Urgent pls help! | last post by:
Hi, I am getting the error: Value of type 'String' cannot be converted to '1-dimensional array of Long'. in the following line for TextBox2.Text field : doc.LoadXml(EDP.ExportPositions(TextBox1.Text, cmbStartDateandTime.SelectedText, cmbEndDateandTime.SelectedText, TextBox2.Text)))
1
2201
by: Patrick.O.Ige | last post by:
I have a simple textbox control <asp:TextBox ID="calendar" runat="server" CssClass="textbox"></asp:TextBox> ( Would be changing it to a calendar control) on a page .I want the user to type in a date e.g 2/06/2008 and hit submit The parameter is being sent to an oracle Db.
0
9925
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9772
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11089
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10809
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10395
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9550
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7104
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4595
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3219
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.