|
Prev: getchar
Next: check file opened or not?
From: George on 2 Apr 2008 03:27 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 2 Apr 2008 04:24 >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 2 Apr 2008 06:45 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 2 Apr 2008 07:20 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 2 Apr 2008 07:21
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 |