From: George on
Hello everyone,


When we use OLESTR to allocate a variable from string literal, like
OLESTR("Hello World"), the memory space for the string literal is on stack,
right?

I can not find official document for this from MSDN.


thanks in advance,
George
From: David Lowndes on
>When we use OLESTR to allocate a variable from string literal, like
>OLESTR("Hello World"), the memory space for the string literal is on stack,
>right?
>
>I can not find official document for this from MSDN.

It is on MSDN - just type OLESTR into the index.

It's documented as a macro that prepends L to the parameter to make a
unicode string literal - L"Hello World".

Dave
From: Ulrich Eckhardt on
George wrote:
> the memory space for the string literal is on stack, right?

String literals have static duration, i.e. they can never be on the stack.

Uli

--
C++ FAQ: http://parashift.com/c++-faq-lite

Sator Laser GmbH
Geschäftsführer: Michael Wöhrmann, Amtsgericht Hamburg HR B62 932
From: George on
Thanks Uli,


1.

You mean OLESTR string literal is in global read-only area? Always?

2.

My previous understanding is if we enable string pool, OLESTR is in the
global accessible area, or else, on stack. Any comments?

3.

My current issue is, I am not sure whether pass pointer pointing to "local"
OLESTR string literal (e.g. OLECHAR* p = OLESTR("Hello"); then passing p to
another function is safe?) from one function to another is safe (if on stack,
not safe)?


regards,
George
From: George on
Hi Dave,


My question is not whether OLECHAR is wchar_t* or char*.

My current issue is, I am not sure whether pass pointer pointing to "local"
OLESTR string literal (e.g. OLECHAR* p = OLESTR("Hello"); then passing p to
another function is safe?) from one function to another is safe (if on stack,
not safe)?


regards,
George
 |  Next  |  Last
Pages: 1 2 3 4 5 6 7 8
Prev: getchar
Next: check file opened or not?