Click here to Skip to main content
15,888,610 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralSyntax Error NOT! Pin
jerry0davis11-Aug-04 3:47
jerry0davis11-Aug-04 3:47 
GeneralRe: Syntax Error NOT! Pin
David Crow11-Aug-04 3:52
David Crow11-Aug-04 3:52 
GeneralRe: Syntax Error NOT! Pin
jerry0davis11-Aug-04 4:00
jerry0davis11-Aug-04 4:00 
GeneralRe: Syntax Error NOT! Pin
David Crow11-Aug-04 4:13
David Crow11-Aug-04 4:13 
GeneralRe: Syntax Error NOT! Pin
Tim Smith11-Aug-04 17:45
Tim Smith11-Aug-04 17:45 
GeneralRe: Syntax Error NOT! Pin
David Crow12-Aug-04 2:38
David Crow12-Aug-04 2:38 
GeneralRe: Syntax Error NOT! Pin
Tim Smith12-Aug-04 3:55
Tim Smith12-Aug-04 3:55 
GeneralRe: Syntax Error NOT! Pin
David Crow12-Aug-04 4:51
David Crow12-Aug-04 4:51 
Tim Smith wrote:
Read the C++ standard section 2.13.4.3.

Then I must also consider these examples that accompany the Concatenation section:

Another way to continue a string is to have two or more consecutive strings. Adjacent string literals will be concatenated to produce a single string. The following example demonstrates this:

"hello " "there" // is equivalent to "hello there"
"hello" "there" // is equivalent to "hellothere"
char *third = "Hello " "there"; // stored as "Hello there\0"

Characters in concatenated strings remain distinct. For example, the strings "\xab" and "3" are concatenated to form "\xab3", rather than the single hex character \xab3.


I believe this site also has a mention of how concatenation is implemented.

Tim Smith wrote:
In translation phase 6 (2.1), adjacent narrow string literals are concatenated and adjacent wide string literals are concatenated. If a narrow string literal token is adjacent to a wide string literal token, the behavior is undefined...

My example did not mix wide and narrow literals, but that's not the point here.

Tim Smith wrote:
The two strings are concatentated.

Indeed, but not in the sense of what one typically thinks of with concatenation (e.g., the "+" operator).

Tim Smith wrote:
They way you describe it is totally wrong.

I respectfully disagree, as it makes perfect sense to me and others I've spoken with about it. Perhaps we are saying the same thing two different ways.

Tim Smith wrote:
It doesn't just ignore the two quotes as also covered in 2.13.4.3.

The compiler sees/stores the two concatenated literals as one single literal.

Tim Smith wrote:
It doesn't just place the two strings after each other in the EXE.

If the two concatenated literals were stored separately, how would the compiler know to find the other piece(s)? It's not like there is a pointer at the end of the first one that points to the start of the second one. Look at some of your latest .exe or .dll files and you'll see that string literals are kept together.

Tim Smith wrote:
Literal string pooling requires that strings be moved around.

Of course, but only when they are "pointed to" by different variables. Given a statement such as:

FindThisName(_T("This is someone's very long name"));
the string literal is not going to be scattered around in multiple places. If it's moved, it's moved altogether. Now consider:

FindThisName(_T("This is someone's very long name"));
PrintThisAddress(_T("123 W. Evergreen St. Suite 9"));
These two string literals are disparate so they will be stored independently of each other. If one is moved, the other might not be, and vice-versa.

Tim Smith wrote:
Also, a backslash is not required.

Of course it's not. I merely used one to show that there were indeed two string literals. Had I used something like:

char *pszName = "A really long string here""...and the rest of it here.";
it might not have been immediately obvious that there was more than one literal.


"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen


GeneralRe: Syntax Error NOT! Pin
Tim Smith11-Aug-04 3:54
Tim Smith11-Aug-04 3:54 
GeneralProcess Injection Pin
Reza Shademani11-Aug-04 3:46
Reza Shademani11-Aug-04 3:46 
GeneralRe: Process Injection Pin
David Crow11-Aug-04 3:57
David Crow11-Aug-04 3:57 
GeneralSuggestions needed - CListCtrl problem Pin
BlackDice11-Aug-04 2:52
BlackDice11-Aug-04 2:52 
GeneralRe: Suggestions needed - CListCtrl problem Pin
V.11-Aug-04 3:08
professionalV.11-Aug-04 3:08 
GeneralRe: Suggestions needed - CListCtrl problem Pin
BlackDice11-Aug-04 3:16
BlackDice11-Aug-04 3:16 
GeneralReleasing MFC projects Pin
KnaveWave11-Aug-04 2:51
KnaveWave11-Aug-04 2:51 
GeneralRe: Releasing MFC projects Pin
Antony M Kancidrowski11-Aug-04 3:19
Antony M Kancidrowski11-Aug-04 3:19 
GeneralRe: Releasing MFC projects Pin
Jaime Stuardo11-Aug-04 3:28
Jaime Stuardo11-Aug-04 3:28 
GeneralQuestion Pin
rfixxxer11-Aug-04 2:01
rfixxxer11-Aug-04 2:01 
GeneralRe: Question Pin
dipeka11-Aug-04 2:15
dipeka11-Aug-04 2:15 
GeneralRe: Question Pin
rfixxxer11-Aug-04 2:51
rfixxxer11-Aug-04 2:51 
GeneralRe: Question Pin
Maximilien11-Aug-04 2:41
Maximilien11-Aug-04 2:41 
GeneralRe: Question Pin
rfixxxer11-Aug-04 2:56
rfixxxer11-Aug-04 2:56 
GeneralRe: Question Pin
Maximilien11-Aug-04 4:26
Maximilien11-Aug-04 4:26 
GeneralRe: Question Pin
rfixxxer11-Aug-04 4:33
rfixxxer11-Aug-04 4:33 
GeneralRe: Question Pin
rfixxxer11-Aug-04 9:04
rfixxxer11-Aug-04 9:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.