220 37337 <CAHSYqdbx5W6zu+0SuOFU7OhiYD7jAcRY-mrw+NY=m+AAAh5_qw@mail.gmail.com> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Hyman Rosen <hyman.rosen@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: `offsetof` in a macro-less, modular world
Date: Thu, 15 Mar 2018 13:07:48 -0400
Lines: 101
Approved: news@gmane.org
Message-ID: <CAHSYqdbx5W6zu+0SuOFU7OhiYD7jAcRY-mrw+NY=m+AAAh5_qw@mail.gmail.com>
References: <c5f5ccc4-3267-442d-8cb2-de1ae103a38e@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/alternative; boundary="f4f5e80aede42a0db10567768908"
X-Trace: blaine.gmane.org 1521133568 19746 195.159.176.226 (15 Mar 2018 17:06:08 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Thu, 15 Mar 2018 17:06:08 +0000 (UTC)
To: std-proposals@isocpp.org
Original-X-From: std-proposals+bncBDKJJPVBQMKRB6OQVLKQKGQEVVQU25Q@isocpp.org Thu Mar 15 18:06:04 2018
Return-path: <std-proposals+bncBDKJJPVBQMKRB6OQVLKQKGQEVVQU25Q@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-wr0-f199.google.com ([209.85.128.199])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBDKJJPVBQMKRB6OQVLKQKGQEVVQU25Q@isocpp.org>)
	id 1ewWKJ-00053f-Uo
	for gclcip-std-proposals@m.gmane.org; Thu, 15 Mar 2018 18:06:04 +0100
Original-Received: by mail-wr0-f199.google.com with SMTP id d18sf4170521wre.6
        for <gclcip-std-proposals@m.gmane.org>; Thu, 15 Mar 2018 10:08:11 -0700 (PDT)
ARC-Seal: i=2; a=rsa-sha256; t=1521133691; cv=pass;
        d=google.com; s=arc-20160816;
        b=OOQ6oAQLile2n40pyoAyeJDdoDbEwRlDOf4amjQak+gzgjqBpV+RnZj1N+TSGIBKhB
         ZsbMHMi9DhQ+2zBwFM8x+1iSNj5ZfaukKkC5EQH1Q6YcwafUEFA1Qmp+k25oOeZeyRwQ
         Z3hruB4nii5XKDWwyEF1+q8LVI1bIKbNRUUECPdL+LRYhZ7D9xuK+l6guUdTxdAS6mu/
         3TondPyiaUVe63ACd25TK+3Dnb3N5IXBZGvoAvwdlumI9betQdVjKYvIPBmZWFOG9WMo
         ZAYuPOeLkKG4YjLFceN8G2EEvGXdjM6TeCifA7iGKuX7ybkX75IkYuMfvvYDbgGmwR21
         MJvQ==
ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
         :list-id:mailing-list:precedence:reply-to:to:subject:message-id:date
         :from:references:in-reply-to:mime-version:arc-authentication-results
         :arc-message-signature:dkim-signature:arc-authentication-results;
        bh=SXwz+h1rEhxOZfNLyI1h/7KznPLP+7TpTqmHa2ySuf0=;
        b=yWzoKewYBmhfUSNYZdyCM9gPbzQDRi1gbCNCDRZWWMKl3w+kf3ktn/K9VNAzq5VS9a
         5AcYpgjOw2S6Zh2BnLKtcbs7ZPddTRVEUjdOKIy3pvxt6nFfOdKLrcOWkCw2ulpILlMb
         WT8MK0BihhhT2UnCqQ4l8AJ4QGdOqESysByjzL/fuLzp+Mq/XCm5sapg/USW9hTDU7sH
         zkRA/jHvV4CRDwLKcSjgCpAQ+2NIxKusgpC7LiZizQYGUNV++5tIdDxi9pBPXZADap7q
         5yhqAGkI2Pd1u7QQLIo7P0rBdu7uUTuW3GKSdTVWLZfU62jKcy8dEqavZYHOkz42RXog
         q+9A==
ARC-Authentication-Results: i=2; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=SzWJMkrA;
       spf=pass (google.com: domain of hyman.rosen@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hyman.rosen@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=mime-version:in-reply-to:references:from:date:message-id:subject:to
         :x-original-sender:x-original-authentication-results:reply-to
         :precedence:mailing-list:list-id:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SXwz+h1rEhxOZfNLyI1h/7KznPLP+7TpTqmHa2ySuf0=;
        b=AkgGiolc8c64TYVyJ9StHtF7Z+vHHYojfw0zhf3IECE4A0CEwxuwrFb6XNU7Lv236E
         /jPy1hU/WpQLIoMOUHeH9V9N+0hyEakA85RhmPG8DE0rSyszyequaB+WOCW5vERAtqbD
         tYxLmDRGSQCer8ZnXIc+PmjhMGDZ+taGsuK59qs2wt+DLt72xyxX5Xee/5U+4ynKcyjR
         1U1A5cfsZT/+WeEssgmd/Qk5Iuoj2ZFvEW05y4gSN55lDDF/Noy3iTo2KNZAADKMfN3V
         7KqRYWbMMF2UDKoCKFMRCqZ3bTyaVpguMWlJhfufv4TD9lnmB0IVcT4+oHDfOMs1nGEW
         0tmg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:mime-version:in-reply-to:references:from:date
         :message-id:subject:to:x-original-sender
         :x-original-authentication-results:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=SXwz+h1rEhxOZfNLyI1h/7KznPLP+7TpTqmHa2ySuf0=;
        b=UJZvFEqjQLv8zFgz4zRnxiM5LxDeFdmfiCP7Lfqn42SCczgRRxeZJAyUKIv8F5VScn
         GGw9tS7Ey++SBLdGDltZINLvznz4a2GcejjXtdFCN1dSJAzspNnZ5uneLCdKcWRS+tGg
         R8Hgjidl52qkRQX26N0+JMW9hTi7IL5RV8aQoGkJcMIQCRO82y2+zk5sCDnXpeD5ez0p
         JWutPpMxhCo0W8lMZLQjEUlYKphz8EzCKEE8OMYUMLbMVWHF/qQwFhFAAw2nlccw5Cdu
         tzRlkRpsZAgGlJntUkfEg0L4ejhUW7n9bai33ItT+O/GajMHkmayLBlp/ewtH0wyUXLk
         Kueg==
X-Gm-Message-State: AElRT7GgWozHJemfDXCTWfsMfXDTu8d2/wRw4oy1FoaCOyTG8vxr5fII
	AECjz8E3JJhEgVdSugmY7QGFDQ==
X-Google-Smtp-Source: AG47ELsnjliCTlZECEnSjaiEOhbiSoY9vi5i6Ufxack0zO1iBWBK6RlxpOqwCGzzrzvtVSLNiVo1lA==
X-Received: by 10.223.187.6 with SMTP id r6mr1067591wrg.9.1521133690980;
        Thu, 15 Mar 2018 10:08:10 -0700 (PDT)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.28.4.212 with SMTP id 203ls1118562wme.0.canary-gmail; Thu, 15
 Mar 2018 10:08:09 -0700 (PDT)
X-Received: by 10.28.184.8 with SMTP id i8mr5836494wmf.52.1521133689140;
        Thu, 15 Mar 2018 10:08:09 -0700 (PDT)
ARC-Seal: i=1; a=rsa-sha256; t=1521133689; cv=none;
        d=google.com; s=arc-20160816;
        b=aep8TzGRkH+i+1tFic0Qe8IoogGraUQjwGmFgsl3EsmCp+bgOEWYI90qJCejiyvBuk
         hTYZ8BrSdc6aRLOtAWl0weg4To9qDkmbZZoogMJLkKXmxT1H8wi9ZVVOE117fxZZ5fgl
         v7iXBV3gnb3IZbyw6IyfI1/GjMu5W8WkDUZpRovPdabFig+q3BhXFeS2HT33ovkjGeDi
         nj6hgealOkqJxeJFEhmnkKI/bJsCy3Ujesg1Fc0/320dFouZIrQIDYxRzxdooARy5RIq
         31rw45Fke4wuhUHosC0TorefsBlzfpEM4n/guTyjWDx+8CMO1AqAJw9HpP1w34NhA6Nh
         ynMg==
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816;
        h=to:subject:message-id:date:from:references:in-reply-to:mime-version
         :dkim-signature:arc-authentication-results;
        bh=pAZOArYBcvJUiYbDB+waQQKYTvUP8XVJdhKqInABr5k=;
        b=jGCDcpihUaf7V8wfOpvpsWI0CtCaK+Jd4F1x3MLa6sYtHJ0VhlfAQout9eJfQFBK4R
         c24O5fLdOA22beWEnrO2hUgCmKDcI7zcJQfAeiDtKgzTZTOqV/jUelgHKuM6chpEGK7z
         0JbxE7pVQbrmQ/j/sRT4/68Olyi8yUq15fJ4r33HiJFMO9OIfc+AToceqbb8HM47OQVk
         UdbSGUNqIgTs89jLmvh7ff6ng+mOAN4brmYz9JOjfs++lPNvJfF4WFvUBoUBMrWFFF5M
         wJn7leMSHuunPzWxwiHAzIiaEaTFCD74Vo4I2ie6nhC6ktkpK/yMZ2FjoORj+J9rg7/w
         bN/w==
ARC-Authentication-Results: i=1; mx.google.com;
       dkim=pass header.i=@gmail.com header.s=20161025 header.b=SzWJMkrA;
       spf=pass (google.com: domain of hyman.rosen@gmail.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=hyman.rosen@gmail.com;
       dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Original-Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41])
        by mx.google.com with SMTPS id v13sor2606836wrg.44.2018.03.15.10.08.09
        for <std-proposals@isocpp.org>
        (Google Transport Security);
        Thu, 15 Mar 2018 10:08:09 -0700 (PDT)
Received-SPF: pass (google.com: domain of hyman.rosen@gmail.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41;
X-Received: by 10.223.209.65 with SMTP id b1mr7449217wri.277.1521133688588;
 Thu, 15 Mar 2018 10:08:08 -0700 (PDT)
Original-Received: by 10.28.55.19 with HTTP; Thu, 15 Mar 2018 10:07:48 -0700 (PDT)
In-Reply-To: <c5f5ccc4-3267-442d-8cb2-de1ae103a38e@isocpp.org>
X-Original-Sender: hyman.rosen@gmail.com
X-Original-Authentication-Results: mx.google.com;       dkim=pass
 header.i=@gmail.com header.s=20161025 header.b=SzWJMkrA;       spf=pass
 (google.com: domain of hyman.rosen@gmail.com designates 209.85.220.41 as
 permitted sender) smtp.mailfrom=hyman.rosen@gmail.com;       dmarc=pass
 (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Spam-Checked-In-Group: std-proposals@isocpp.org
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:37337
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/37337>

--f4f5e80aede42a0db10567768908
Content-Type: text/plain; charset="UTF-8"

On Thu, Mar 15, 2018 at 12:12 PM, Nicol Bolas <jmckesson@gmail.com> wrote:

> The C standard library defines a large number of things that are macros.
> In the vast majority of cases, these are constants or functions, which can
> in C++ code be converted into `constexpr` variables or actual functions.
> For all intents and purposes, such constructs can be drop-in replacements
> for the C macros, which allows us to still work with them in a modular
> standard library that doesn't allow macros.
>
> `offsetof` is a special case because it's not a function. Or at least,
> it's not a function that C++ at present allows you to write. Without
> reflection, there is no way to pass a typename or member variable as a
> function parameter. And while there are ways we can work around it, none of
> those ways would be drop-in replacements for `offsetof`; the user would
> have to change their code.
>
> And even ignoring the non-drop-in part, there is currently no C++
> replacement for `offsetof`. As modules moves forward, are there plans to
> resolve this issue and similar ones (beside the "let's get modules to
> export macros" plan)?
>

The Standard requires (in *[headers]*) that offsetof be a macro, so a
library that bans macros perforce cannot use offsetof (or assert, setjmp,
va_arg, va_end, and va_start).  If you want to change that, then make
offsetof a built-in keyword, just like decltype and sizeof.

Also, what does it mean, "a modular standard library that doesn't use
macros"?  A module can (or must, I suppose, for now) have an exported
interface that does not provide macros to its users, but that does not
prevent the code in the module from including header files and using macros
as part of its implementation.

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdbx5W6zu%2B0SuOFU7OhiYD7jAcRY-mrw%2BNY%3Dm%2BAAAh5_qw%40mail.gmail.com.

--f4f5e80aede42a0db10567768908
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_extra"><div class=3D"gmail_quote">On T=
hu, Mar 15, 2018 at 12:12 PM, Nicol Bolas <span dir=3D"ltr">&lt;<a href=3D"=
mailto:jmckesson@gmail.com" target=3D"_blank">jmckesson@gmail.com</a>&gt;</=
span> wrote:<br><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0=
px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=
=3D"ltr">The C standard library defines a large number of things that are m=
acros. In the vast majority of cases, these are constants or functions, whi=
ch can in C++ code be converted into `constexpr` variables or actual functi=
ons. For all intents and purposes, such constructs can be drop-in replaceme=
nts for the C macros, which allows us to still work with them in a modular =
standard library that doesn&#39;t allow macros.<br><br>`offsetof` is a spec=
ial case because it&#39;s not a function. Or at least, it&#39;s not a funct=
ion that C++ at present allows you to write. Without reflection, there is n=
o way to pass a typename or member variable as a function parameter. And wh=
ile there are ways we can work around it, none of those ways would be drop-=
in replacements for `offsetof`; the user would have to change their code.<b=
r><br>And even ignoring the non-drop-in part, there is currently no C++ rep=
lacement for `offsetof`. As modules moves forward, are there plans to resol=
ve this issue and similar ones (beside the &quot;let&#39;s get modules to e=
xport macros&quot; plan)?</div></blockquote><div><br>The Standard requires =
(in <b>[headers]</b>) that <font face=3D"monospace, monospace">offsetof</fo=
nt> be a macro, so a library that bans macros perforce cannot use <font fac=
e=3D"monospace, monospace">offsetof=C2=A0</font>(or <font face=3D"monospace=
, monospace">assert</font>, <font face=3D"monospace, monospace">setjmp</fon=
t>, <font face=3D"monospace, monospace">va_arg</font>, <font face=3D"monosp=
ace, monospace">va_end</font>, and <font face=3D"monospace, monospace">va_s=
tart</font>).=C2=A0 If you want to change that, then make <font face=3D"mon=
ospace, monospace">offsetof</font> a built-in keyword, just like <font face=
=3D"monospace, monospace">decltype</font> and <font face=3D"monospace, mono=
space">sizeof</font>.<br><br>Also, what does it mean, &quot;a modular stand=
ard library that doesn&#39;t use macros&quot;?=C2=A0 A module can (or must,=
 I suppose, for now) have an exported interface that does not provide macro=
s to its users, but that does not prevent the code in the module from inclu=
ding header files and using macros as part of its implementation.</div></di=
v></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/CAHSYqdbx5W6zu%2B0SuOFU7OhiYD7jAcRY-m=
rw%2BNY%3Dm%2BAAAh5_qw%40mail.gmail.com?utm_medium=3Demail&utm_source=3Dfoo=
ter">https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/CAHSYqdbx=
5W6zu%2B0SuOFU7OhiYD7jAcRY-mrw%2BNY%3Dm%2BAAAh5_qw%40mail.gmail.com</a>.<br=
 />

--f4f5e80aede42a0db10567768908--

.
