0

Is there a portable way to print a message from the C preprocessor?

gcc preprocessor can print messages. How to print the source code line numbers in the messages? Thanks.

user1424739
  • 11,937
  • 17
  • 63
  • 152
  • `#warning` and `#pragma message` precede the message with the line number, is that not sufficient? – Nate Eldredge Mar 22 '21 at 17:02
  • Could you show the exact text to demonstrate the effect? – user1424739 Mar 22 '21 at 17:11
  • For example, `#pragma message "This is a message"` makes the compiler output `foo.c:4:9: note: #pragma message: This is a message`, where `4` is the line number where the `#pragma` appears. (And `9` is the column where the message begins.) – Nate Eldredge Mar 22 '21 at 19:12

0 Answers0