Path: csiph.com!eternal-september.org!feeder.eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: Keith Thompson Newsgroups: comp.lang.c++ Subject: Re: An example: code to list exports of a Windows DLL. Date: Tue, 20 Aug 2019 02:18:24 -0700 Organization: None to speak of Lines: 65 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: reader02.eternal-september.org; posting-host="eda0362a42d89c1a502f45f546af142c"; logging-data="15014"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+PaqaYLH8BG6kbMEE8fhJp" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1 (gnu/linux) Cancel-Lock: sha1:5AX9z2D1aMoFEiPxd3RJ/fQk0yE= sha1:uUpV6ui/FLrR4/A4XTJ8xOM1JM8= Xref: csiph.com comp.lang.c++:67802 David Brown writes: > On 20/08/2019 03:31, Keith Thompson wrote: >> "Alf P. Steinbach" writes: >>> On 19.08.2019 21:44, Richard wrote: >>>> "Alf P. Steinbach" spake the secret code >>>> thusly: >>>> >>>>> The $ things in the following code are macros from the specified >>>>> header-only library on GitHub. >>>> >>>> Can you tell me where in the standard it allows for $ to be part of an >>>> identifier? >>>> >>>> I'm looking at 5.10 in N4659 (Draft C++17) and don't see it. >>> >>> In the future you might risk that people think you're a total novice, >>> one who doesn't even know the basics of identifiers in C++. >> >> Then I'll risk the same thing. Can you explain where C++17 permits $ >> in identifiers (or where it permits compilers to permit it)? > > It doesn't. > >> I believe that both foo$bar and foo\u0024bar violate a diagnosable rule >> and therefore require a diagnostic from any conforming compiler (which >> implies that gcc is non-conforming). > > You get the warning with "-Wpedantic" and an appropriate "-std" C++ > standard (and perhaps an appropriate version of gcc). Can you demonstrate that? I haven't been able to do so, with several versions of g++ (up to and including a bleeding-edge version I built from source a week and a half ago). Here's the test case I used: #include int main() { const int foo$bar = 42; std::cout << foo$bar << "\n"; } compiled with "g++ -Wpedantic -std=c++17". No warning from any version I have on my system. >> Or perhaps I'm missing something (always a real possibility). > > What you are missing is that $ is accepted in identifiers in many > compilers, and Alf simply does not care that it is not supported in the > standards as long as it is supported in the compilers he uses. Please don't assume that I missed it just because I didn't discuss it. My post was about whether the C++ standard permits compilers to permit $ in identifiers. (I presume we can all agree that compilers aren't *required* to accept $ in identifiers.) C++11 clearly does permit it, since it explicitly allows "other implementation-defined characters" in identifiers. C++17 apparently does not, since it dropped that wording (apparently in the belief that it was redundant, but I don't believe it was). [...] -- Keith Thompson (The_Other_Keith) kst-u@mib.org Will write code for food. void Void(void) { Void(); } /* The recursive call of the void */