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

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


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

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


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
Thanks for your registration, follow us on our social networks to keep up-to-date