Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #8059
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!news.musoftware.de!wum.musoftware.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail |
|---|---|
| From | Ian Collins <ian-news@hotmail.com> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: #define - in header or cpp |
| Date | Fri, 22 Jul 2011 09:35:45 +1200 |
| Lines | 33 |
| Message-ID | <98rkdhFroiU4@mid.individual.net> (permalink) |
| References | <d0a4638c-2b91-4099-8718-cb47ada19e53@h14g2000yqd.googlegroups.com> <j09gu1$10qq$1@news.ett.com.ua> <e0b93$4e28719b$506c0d9c$16489@news.chello.at> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | individual.net H0m2DcbKRlxW6UqRn89HbgrF1Uq6UGw9ulkPQP59N8yuTqTJb1 |
| Cancel-Lock | sha1:dcMM/5Q+dwIJ3RJfEurTNj+wpC8= |
| User-Agent | Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4 |
| In-Reply-To | <e0b93$4e28719b$506c0d9c$16489@news.chello.at> |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.c++:8059 |
Show key headers only | View raw
On 07/22/11 06:36 AM, Paul Brettschneider wrote:
> Balog Pal wrote:
>
>> 2. #define is just for last resort -- use C++ native stuff wherever
>> possible.
>
> Somewhat off-topic: What is the C++-way of implementing string literal
> macros for use with concetenation?
>
> What I mean is this:
>
> #define CONTROL_SEQUENCE "\xde\xad\xbe\xef"
> static const char control_sequence[] = "\xde\xad\xbe\xef";
static const std::string control_sequence = "\xde\xad\xbe\xef";
> static const char *f1()
> {
> return "Test " CONTROL_SEQUENCE " string"; // Compiles but ugly
> }
> static const char *f2()
> {
> return "Test " control_sequence " string"; // Error
> }
static std::string f2()
{
return "Test " + control_sequence + " string"; // No error
}
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
#define - in header or cpp Christopher <cpisz@austin.rr.com> - 2011-07-21 08:11 -0700
Re: #define - in header or cpp Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-21 11:27 -0400
Re: #define - in header or cpp "Balog Pal" <pasa@lib.hu> - 2011-07-21 17:34 +0200
Re: #define - in header or cpp Christopher <cpisz@austin.rr.com> - 2011-07-21 10:42 -0700
Re: #define - in header or cpp Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-07-21 20:36 +0200
Re: #define - in header or cpp Victor Bazarov <v.bazarov@comcast.invalid> - 2011-07-21 15:21 -0400
Re: #define - in header or cpp Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-07-21 23:27 +0200
Re: #define - in header or cpp Ian Collins <ian-news@hotmail.com> - 2011-07-22 09:35 +1200
Re: #define - in header or cpp Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-07-21 23:57 +0200
Re: #define - in header or cpp Thomas Boell <tboell@domain.invalid> - 2011-07-22 01:06 +0200
Re: #define - in header or cpp Ian Collins <ian-news@hotmail.com> - 2011-07-22 11:14 +1200
Re: #define - in header or cpp Paul Brettschneider <paul.brettschneider@yahoo.fr> - 2011-07-22 08:49 +0200
Re: #define - in header or cpp Joe Greer <jgreer@doubletake.com> - 2011-07-22 13:23 +0000
Re: #define - in header or cpp James Kanze <james.kanze@gmail.com> - 2011-07-22 12:58 -0700
Re: #define - in header or cpp James Kanze <james.kanze@gmail.com> - 2011-07-22 12:51 -0700
Re: #define - in header or cpp gwowen <gwowen@gmail.com> - 2011-07-22 00:29 -0700
Re: #define - in header or cpp Christopher <cpisz@austin.rr.com> - 2011-07-22 15:56 -0700
Re: #define - in header or cpp Juha Nieminen <nospam@thanks.invalid> - 2011-07-22 14:33 +0000
Re: #define - in header or cpp Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-07-26 11:26 +0000
Re: #define - in header or cpp Juha Nieminen <nospam@thanks.invalid> - 2011-07-26 16:14 +0000
csiph-web