Ashwin Nanjappa
Ashwin Nanjappa

Reputation: 78528

Visual C++: How to embed and display a compile time message in code?

Is there a way to embed a message in code that is displayed during compile-time when that piece of code is being compiled? The messages are diagnostic in nature and should not modify or abort the compile process.

(Disclaimer: I know the answer to this question. I didn't find it asked on Stack Overflow and I think it would be an useful addition to the knowledge base here.)

Upvotes: 12

Views: 12195

Answers (1)

Nick Dandoulakis
Nick Dandoulakis

Reputation: 43130

This is one way to do it:

#pragma message("Your Message Here")

https://msdn.microsoft.com/en-us/library/x7dkzch2.aspx

Upvotes: 19

Related Questions