Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #8062

Re: #define - in header or cpp

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!.POSTED!not-for-mail
From Thomas Boell <tboell@domain.invalid>
Newsgroups comp.lang.c++
Subject Re: #define - in header or cpp
Date Fri, 22 Jul 2011 01:06:03 +0200
Organization albasani.net
Lines 41
Message-ID <20110722010603.586306a4@arcadia> (permalink)
References <d0a4638c-2b91-4099-8718-cb47ada19e53@h14g2000yqd.googlegroups.com> <j09gu1$10qq$1@news.ett.com.ua> <e0b93$4e28719b$506c0d9c$16489@news.chello.at> <98rkdhFroiU4@mid.individual.net>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
X-Trace news.albasani.net gcclJgdVzEoTDVSX03dcGzQymaiwTzRqkgRDoWC6TW74WLdKhEHH2PIVHGGsIdtdHxDuaW27t1HsFlqsRdKYMCAfifTrBXlk7ycVmh/Bo34mG/Wdxa90RNvqGR0jIlLX
NNTP-Posting-Date Thu, 21 Jul 2011 23:06:03 +0000 (UTC)
Injection-Info news.albasani.net; logging-data="6Qwu45WUT+obm0dh7diEDnBHIfvdkljiTtNUJSYbwqHU+wiNGUcHyhHPmZHd3GoSMFnmpLf51zxng36KCzF5H2Qs63Jc1Gb6t5GmfYIXfXy3WLrEa0sM6hCvNZvyp5t5"; mail-complaints-to="abuse@albasani.net"
X-Newsreader Claws Mail 3.7.9 (GTK+ 2.24.4; i686-pc-linux-gnu)
Cancel-Lock sha1:RdmWUFg/A7rz8VSQz6OW4bT1HD8=
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:8062

Show key headers only | View raw


On Fri, 22 Jul 2011 09:35:45 +1200
Ian Collins <ian-news@hotmail.com> wrote:

> 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
> }

Which is, of course, something totally different than Paul's
original example...

What is the problem with concatenating string literals at compile time,
anyway?

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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