473,385 Members | 1,474 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Quote-Dot-Quote Operator

I'm taking a look at some existing C++ code and trying to figure out
what it's doing. It says:

static char const *abc[] = {
"DEF", DEF,
"GHI", PQR_PQR_STRING "."
PQR_PQR_FUNC(PQR_VAR1, PQR_VAR2),
"JKL", JKL,
"MNO", "M_N_O",
0
};

where <DEFand <JKLare defined in <#include>ed header files in the
local directory, and I assume all the <PQR_*entities are included in
header files somewhere. (I've changed all the variable names from
what the existing code says so that I can post this here.)

Now, apparently this is saying that the type of expression
<PQR_PQR_STRING "." PQR_PQR_FUNC(PQR_VAR1, PQR_VAR2)is <char *>, be-
cause it's included as an element of the <abcarray. But is
<PQR_PQR_STRING "." PQR_PQR_FUNC(PQR_VAR1, PQR_VAR2)even _valid syn-
tax_? It seems to be implying that quote-dot-quote is a valid opera-
tor, and if it is, that's news to me.

If someone can tell me why this compiles and what it means, I'd be
really, really grateful.

---Kevin Simonson

"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
Jun 27 '08 #1
4 1775
kv******@hotmail.com wrote:
I'm taking a look at some existing C++ code and trying to figure out
what it's doing. It says:

static char const *abc[] = {
"DEF", DEF,
"GHI", PQR_PQR_STRING "."
PQR_PQR_FUNC(PQR_VAR1, PQR_VAR2),
"JKL", JKL,
"MNO", "M_N_O",
0
};

where <DEFand <JKLare defined in <#include>ed header files in the
local directory, and I assume all the <PQR_*entities are included in
header files somewhere. (I've changed all the variable names from
what the existing code says so that I can post this here.)

Now, apparently this is saying that the type of expression
<PQR_PQR_STRING "." PQR_PQR_FUNC(PQR_VAR1, PQR_VAR2)is <char *>, be-
cause it's included as an element of the <abcarray. But is
<PQR_PQR_STRING "." PQR_PQR_FUNC(PQR_VAR1, PQR_VAR2)even _valid syn-
tax_? It seems to be implying that quote-dot-quote is a valid opera-
tor, and if it is, that's news to me.
Hard to say without seeing the macros. They probably produce quoted
strings. The pre-processor will concatenate string literals into one
token, so

"1" "." "2" will be concatenated to "1.2".

--
Ian Collins.
Jun 27 '08 #2
Hi!

Stefan Ram schrieb:
Preprocessing directives are executed and macro invocations
are expanded in translation phase 4, while adjacent ordinary
string literal tokens are concatenated in translation phase 6
(ISO/IEC ISO/IEC 14882:2003(E), 2.1).
Should that me the compiler concatenates them instead of the preprocessor?

Frank
Jun 27 '08 #3
On 2008-06-14 15:25, Frank Birbacher wrote:
Hi!

Stefan Ram schrieb:
> Preprocessing directives are executed and macro invocations
are expanded in translation phase 4, while adjacent ordinary
string literal tokens are concatenated in translation phase 6
(ISO/IEC ISO/IEC 14882:2003(E), 2.1).

Should that me the compiler concatenates them instead of the preprocessor?
Not necessarily, the standard does not define who does what.

--
Erik Wikström
Jun 27 '08 #4
On Jun 14, 9:07 pm, Erik Wikström <Erik-wikst...@telia.comwrote:
On 2008-06-14 15:25, Frank Birbacher wrote:
Stefan Ram schrieb:
Preprocessing directives are executed and macro invocations
are expanded in translation phase 4, while adjacent ordinary
string literal tokens are concatenated in translation phase 6
(ISO/IEC ISO/IEC 14882:2003(E), 2.1).
Should that me the compiler concatenates them instead of the
preprocessor?
Not necessarily, the standard does not define who does what.
More exactly, it defines it differently in different places.
Section 16 is "Preprocessing directives", treats the
preprocessor, and there's certainly no concatentation of string
literals there. On the other hand, "Each preprocessing token is
converted into a token" in phase 7, which certainly sounds to me
like everything earlier (including the concatenation of string
literals in phase 6) is preprocessor.

I don't think it really matters. The important thing is that it
happens. Before "The resulting tokens are syntactically and
semantically analyzed and translated as a translation unit."
(Which is interesting in itself. Why didn't they just define a
production for concatenating string literals?)

--
James Kanze (GABI Software) email:ja*********@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34
Jun 27 '08 #5

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

Similar topics

7
by: Paul Davis | last post by:
I'd like to overload 'comma' to define a concatenation operator for integer-like classes. I've got some first ideas, but I'd appreciate a sanity check. The concatenation operator needs to so...
30
by: | last post by:
I have not posted to comp.lang.c++ (or comp.lang.c++.moderated) before. In general when I have a C++ question I look for answers in "The C++ Programming Language, Third Edition" by Stroustrup....
1
by: joesoap | last post by:
Hi can anybody please tell me what is wrong with my ostream operator??? this is the output i get using the 3 attached files. this is the output after i run assignment2 -joesoap #include...
5
by: Jason | last post by:
Hello. I am trying to learn how operator overloading works so I wrote a simple class to help me practice. I understand the basic opertoar overload like + - / *, but when I try to overload more...
0
by: Martin Magnusson | last post by:
I have defined a number of custom stream buffers with corresponding in and out streams for IO operations in my program, such as IO::output, IO::warning and IO::debug. Now, the debug stream should...
3
by: Sensei | last post by:
Hi. I have a problem with a C++ code I can't resolve, or better, I can't see what the problem should be! Here's an excerpt of the incriminated code: === bspalgo.cpp // THAT'S THE BAD...
14
by: lutorm | last post by:
Hi everyone, I'm trying to use istream_iterators to read a file consisting of pairs of numbers. To do this, I wrote the following: #include <fstream> #include <vector> #include <iterator> ...
6
by: YUY0x7 | last post by:
Hi, I am having a bit of trouble with a specialization of operator<<. Here goes: class MyStream { }; template <typename T> MyStream& operator<<(MyStream& lhs, T const &)
5
by: raylopez99 | last post by:
I need an example of a managed overloaded assignment operator for a reference class, so I can equate two classes A1 and A2, say called ARefClass, in this manner: A1=A2;. For some strange reason...
3
by: y-man | last post by:
Hi, I am trying to get an overloaded operator to work inside the class it works on. The situation is something like this: main.cc: #include "object.hh" #include "somefile.hh" object obj,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.