Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Ian Collins Newsgroups: comp.lang.c++ Subject: Re: An example: code to list exports of a Windows DLL. Date: Tue, 20 Aug 2019 22:22:00 +1200 Lines: 61 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net TpW0WVRdUhnIvFUoUP0etAOYyjV9+WDNTXl/1iEuRotMU0FlNL Cancel-Lock: sha1:I4tTY5wYvIbuEfblHW9XpIkzI+E= User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 In-Reply-To: Content-Language: en-US Xref: csiph.com comp.lang.c++:67803 On 20/08/2019 21:18, Keith Thompson wrote: > 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. Try clang: $ clang++ -Wpedantic -std=c++17 /tmp/x.cc /tmp/x.cc:3:18: warning: '$' in identifier [-Wdollar-in-identifier-extension] const int foo$bar = 42; ^ /tmp/x.cc:4:21: warning: '$' in identifier [-Wdollar-in-identifier-extension] std::cout << foo$bar << "\n"; ^ 2 warnings generated. $ clang++ --version clang version 8.0.1-svn363027-1~exp1~20190611211629.77 (branches/release_80) -- Ian.