Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: C++
Expertise: Beginner
Mar 1, 2007

Create #pragma Messages to Reach the Source of a Message

This macro is for use in #pragma messages. It allows you to double-click on an output message and automatically open the file in the editor at the source #pragma message statement:

#define STRING2(x) #x
#define STRING(x) STRING2(x)
#define FILE_LOC __FILE__ "(" STRING(__LINE___) ") : "
Usage:

#pragma message(FILE_LOC "Your message here")
When compiling, this will generate output like:

c:\My Projects\MyFile.cpp(27) : Your message here
When you double-click on the message, MyFile.cpp will open to line 27. Note that this is IDE-dependent; it relies on mimicking the format that Visual Studio uses for build warnings and errors. I've used it in Visual Studio 6 and 2005; your mileage may vary in other IDEs.

Alison Lomaka
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap