Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > comp.std.c++ > #752

Re: Macro replacement interpretation

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!peer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!Xl.tags.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!buffer1.nntp.dca1.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Thu, 02 Apr 2015 13:30:01 -0500
Return-Path <cppmods@glengoyne.dreamhost.com>
Sender std-cpp-request@vandevoorde.com
Approved james.dennett@gmail.com
Message-ID <551C7043.1010408@verizon.net> (permalink)
Newsgroups comp.std.c++
From James Kuyper <jameskuyper@verizon.net>
Subject Re: Macro replacement interpretation
Organization Self
References <meiemi$vtj$1@dont-email.me> <RdednfuKHuOQRonInZ2dnUVZ8kednZ2d@giganews.com> <mf8vtn$bp4$1@dont-email.me> <551990B5.3000601@verizon.net> <HIKdnYyUVLGDiYbInZ2dnUVZ7tudnZ2d@giganews.com>
Content-Type text/plain; charset=utf-8
X-Original-Date Wed, 01 Apr 2015 18:25:07 -0400
X-Submission-Address std-cpp-submit@vandevoorde.com
Date Thu, 2 Apr 2015 13:24:23 CST
Lines 50
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-7JS62uH87U57BAV0zQeoBmYWBxHhST8OAroeSuPHOyr9Qdpbbh6GR4st9lsJP7PL0+184cS0fG+7GWx!FQD2SJvJQgYEESzX9UGRZmu2ATTSCKf7S8S3k2wVCi+gEmCrnM13gw==
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 3224
X-Received-Bytes 3367
X-Received-Body-CRC 3628434234
Xref csiph.com comp.std.c++:752

Show key headers only | View raw


On 04/01/2015 06:38 PM, Jakob Bohm wrote:
>
> On 31/03/2015 23:38, James Kuyper wrote:
>
>>
>> On 03/30/2015 02:21 PM, Edward Diener wrote:
>>
>>>
>>> On 3/29/2015 5:01 AM, Jakob Bohm wrote:
...
>>>>  Thus it might be
>>>> cumbersome to use the standard syntax to implement
>>>> int printf(const char *fmt, ...) as a macro that invokes
>>>> int fprintf_private(FILE *f, const char *fmt, size_t fmtlen, ...).
...
>> In order for printf() to be defined as macro that calls
>> fprintf_private() while allowing it be called with only a format string
>> (as is legal), it would have to look something like this:
>>
>> // Remove any pre-existing #define of printf() by the implementation.
>> #undef printf
>> #define printf(...) fprintf_private(stdout, \\
>>          count_va_args(#__VA_ARGS__), __VA_ARGS__)
>>
>>
> Naah, I wanted to pass the length of the format string (in chars), not
> the argument count, to illustrate use of the actual last mandatory
> argument.

In that case, then it's much simpler: replace count_va_args() with
sizeof or strlen(). The only clue in your message was the fact that the
parameter's name was "fmtlen".

> Which was exactly my point.

I was responding to Edward Diener, explaining your point. I often do
that if the person who made the point hasn't gotten around to responding
yet. I apologize if you would have preferred to explain it yourself - I
sometimes get impatient - but sometimes such arguments carry more weight
if they are made by multiple people. Sometimes it helps to explain the
same thing multiple different ways.


--
[ 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 | NextPrevious in thread | Next in thread | Find similar


Thread

Macro replacement interpretation Edward Diener <eldiener@tropicsoft.invalid> - 2015-03-26 12:09 -0600
  Re: Macro replacement interpretation James Kuyper <jameskuyper@verizon.net> - 2015-03-27 14:07 -0600
  Re: Macro replacement interpretation Jakob Bohm <jb-usenet@wisemo.com> - 2015-03-29 03:01 -0600
    Re: Macro replacement interpretation Francis Glassborow <francis.glassborow@btinternet.com> - 2015-03-30 12:20 -0600
    Re: Macro replacement interpretation Edward Diener <eldiener@tropicsoft.invalid> - 2015-03-30 12:21 -0600
      Re: Macro replacement interpretation Francis Glassborow <francis.glassborow@btinternet.com> - 2015-03-31 15:39 -0600
        Re: Macro replacement interpretation James Kuyper <jameskuyper@verizon.net> - 2015-04-01 16:39 -0600
      Re: Macro replacement interpretation James Kuyper <jameskuyper@verizon.net> - 2015-03-31 15:38 -0600
        Re: Macro replacement interpretation Jakob Bohm <jb-usenet@wisemo.com> - 2015-04-01 16:38 -0600
          Re: Macro replacement interpretation James Kuyper <jameskuyper@verizon.net> - 2015-04-02 13:24 -0600
            Re: Macro replacement interpretation Francis Glassborow <francis.glassborow@btinternet.com> - 2015-04-03 14:30 -0600
        Re: Macro replacement interpretation Edward Diener <eldiener@tropicsoft.invalid> - 2015-04-03 14:30 -0600
          Re: Macro replacement interpretation James Kuyper <jameskuyper@verizon.net> - 2015-04-04 15:50 -0600

csiph-web