Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Daniel Krügler <daniel.kruegler@googlemail.com> |
|---|---|
| Newsgroups | comp.std.c++ |
| Subject | Re: user-defined literals and macros |
| Date | 2011-10-31 11:12 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <j8k9dh$6b6$1@dont-email.me> (permalink) |
| References | <21848168.4112.1319981727733.JavaMail.geo-discussion-forums@yqbl36> |
Am 30.10.2011 19:09, schrieb cryptooctoploid@gmail.com:
> Consider:
> % cat liter.cpp
> #define BAR "foo"
> int main()
> {
> char *foobar("foo/"BAR);
> }
>
> % g++ liter.cpp -std=gnu++0x
> liter.cpp: In function ‘int main()’:
> liter.cpp:4:16: error: unable to find user-defined string literal operator ‘operator"" BAR’
>
> Is this the expected behavior?
Yes, this is a known backward-compatibility break of C++11, it is listed
in annex C.2.1, 2.5:
<quote>
Change: User-defined literal string support
Rationale: Required for new features.
Effect on original feature: Valid C++ 2003 code may fail to compile or
produce different results in this International Standard, as the
following example illustrates.
#define _x "there"
"hello"_x // #1
Previously, #1 would have consisted of two separate preprocessing tokens
and the macro _x would have been expanded. In this International
Standard, #1 consists of a single preprocessing tokens, so the macro
is not expanded.
</quote>
HTH & Greetings from Bremen,
Daniel Krügler
--
[ comp.std.c++ is moderated. To submit articles, try posting with your ]
[ newsreader. If that fails, use mailto:std-cpp-submit@vandevoorde.com ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Back to comp.std.c++ | Previous | Next — Previous in thread | Find similar
user-defined literals and macros cryptooctoploid@gmail.com - 2011-10-30 11:09 -0700
Re: user-defined literals and macros Johannes Schaub <schaub.johannes@googlemail.com> - 2011-10-31 11:10 -0700
Re: user-defined literals and macros David Krauss <potswa@gmail.com> - 2011-10-31 11:11 -0700
Re: user-defined literals and macros Ed Smith-Rowland <3dw4rd@verizon.net> - 2011-10-31 11:11 -0700
Re: user-defined literals and macros Ed Smith-Rowland<3dw4rd@verizon.net> - 2011-11-01 11:14 -0700
Re: user-defined literals and macros Daniel Krügler <daniel.kruegler@googlemail.com> - 2011-10-31 11:12 -0700
csiph-web