This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][RFC] Add #pragma message ... to gcc/g++


Joseph S. Myers wrote:
On Tue, 22 Jul 2008, Diego Novillo wrote:

On Fri, Jul 18, 2008 at 10:18, Simon Baldwin <simonb@google.com> wrote:

+ static void
+ handle_pragma_message (cpp_reader *ARG_UNUSED(dummy))
+ {
Needs comment.

Already pointed out by others, and added in an update to the patch, posted to the list yesterday.



+ if (TREE_STRING_LENGTH (message) > 1)
+ fnotice (stdout, "%s\n", TREE_STRING_POINTER (message));
Shouldn't this go to stderr?  Or are you purposely separating these
messages from warning/errors.

The idea and the patch are fine with me. I would be overstepping my
maintenance bounds if I approved it, though. Joseph, could you
comment on this patch?

Not only should it go to stderr, it should go through the diagnostic machinery, and be properly labelled to distinguish it from normal diagnostics. I suggest inform ("#pragma message: %s", message_text) to make it clear that the diagnostic is coming from this pragma.

This feature is purposely designed to match the documented behaviour of both icc and MSVC.


icc writes such messages to stdout, not to stderr. I don't see a particular problem with writing to stderr if it's deemed more desirable. But since stderr is intended for error messages and warning, and '#pragma message ...' is by design neither warning nor error, using stderr rather than stdout seems a bit misleading. And writing to stderr waters down compatibility with icc.

Both icc and MSVC write the given message as plain unadorned text, without any introductory preamble at all. Having gcc add its own preamble further considerably dilutes compatibility with these other compilers. Users sometimes need complete control over message formats. A conscientious user could, if they wished, add this preamble, or any other, to each use of '#pragma message ...' as it stands, but if gcc automatically adds preamble, a user is powerless to sidestep or suppress it if required for any reason.

In addition, I believe TREE_STRING_POINTER will be in the execution character set here, not the source character set or the locale character set. For diagnostics, you should in principle convert to the locale character set (it may be necessary to export some suitable conversion interface from libcpp) - though given other existing bugs in this area this isn't critical.

Noted. Thank you.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]