________________________________________ From: Boost [boost-bounces@lists.boost.org] on behalf of Edward Diener via Boost [boost@lists.boost.org] Sent: 03 December 2017 03:44
To: boost@lists.boost.org Cc: Edward Diener Subject: Re: [boost] BOOST_PRAGMA_MESSAGE?
On 12/2/2017 10:27 PM, Peter Dimov via Boost wrote: Edward Diener wrote:
The BOOST_PRAGMA_MESSAGE which you showed expands its parameter to a quoted string by the eventual use of the # as the stringizing operator in the macro expansion.
Ah, you're saying that I made an error. No, I haven't, what I posted works, I copied and pasted the real output.
You are correct.
So your original post was a question as to what library the macro should be added ? I vote for core.
Please note that the Clang compiler needs some attention here. For some reason Clang defines __GNUC__ as 4.2.1 so it is necessary to test for e.g. __clang_major__ before testing for __GNUC__. After some experimenting I can offer you this: #if defined(__clang_major__) #define STR(X) #X #define DEFER(M,...) M(__VA_ARGS__) #define BOOST_PRAGMA_MESSAGE(X) _Pragma(STR(message (X " at line " DEFER(STR,__LINE__)))) #elif defined( __GNUC__ ) .... the rest of your code. My output is like this: pragma.cpp:23:1: warning: something at line 23 [-W#pragma-messages] BOOST_PRAGMA_MESSAGE( "something" ) ^ pragma.cpp:11:33: note: expanded from macro 'BOOST_PRAGMA_MESSAGE' #define BOOST_PRAGMA_MESSAGE(X) _Pragma(STR(message (X " at line " DEFER... ^ <scratch space>:3:2: note: expanded from here message ("something" " at line " DEFER(STR,__LINE__)) I have tried that with Clang 3.6, 4.0 and 5.0 I hope this helps John Fletcher _______________________________________________ Unsubscribe & other changes: https://emea01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.boost.org%2Fmailman%2Flistinfo.cgi%2Fboost&data=02%7C01%7CJ.P.Fletcher%40aston.ac.uk%7C37efe8f718cb406c50ca08d53a00464f%7Ca085950c4c2544d5945ab852fa44a221%7C0%7C0%7C636478695210047580&sdata=XRTmIR%2BTfwXJmPs90uGvMgrp9PXxpJoMdjznMjlqW20%3D&reserved=0