472,356 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

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 7598
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**************@TK2MSFTNGP12.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.asianetindia.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::Exception% );
int main()
{
R r;
System::Exception 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*************@TK2MSFTNGP15.phx.gbl...
"Nishant Sivakumar" <ni**@nospam.asianetindia.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::Exception% );
int main()
{
R r;
System::Exception e;
}

-hg

Nov 17 '05 #4
"Nishant Sivakumar" <ni**@nospam.asianetindia.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******@club-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 specialiazations 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(void) ;

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**********@remove.ix-n.net> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
"Arnaud Debaene" <ad******@club-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 specialiazations 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
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: ...
27
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...
3
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...
15
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
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...
1
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...
2
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 : ...
0
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 : ...
1
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
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 required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
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 file that would suck all files in the folder and...
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 credentials and received a successful connection...
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 technical details, Gmail likely implements measures...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
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 starter kit that's not only easy to use but also...
0
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

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.