VC++: how to place a "positioned" #pragma message? 
Author Message
 VC++: how to place a "positioned" #pragma message?

I use #pragma message very often to mark something in my sources I must
further work on. Now I have two problems:

1) There seems to be no possibility to give the generated message a position
information like a compiler error or a warning. I did some experiments with
__FILE__ and __LINE__:

#pragma message(__FILE__ "(" __LINE__ "): " "... this is the message")

This would be successful if __LINE__ could be expanded as text, but in
reality is becomes an integer number which could not be appended to the
string coming from __FILE__. I read the documentations about preprocessor
statements but didn't get much more clever. How to concat __FILE__ and
__LINE__ to get something like "filename(linenum)" ?

2) I want to shorten typing this #pragma, especially if it contains
complicated macro constructs. I want to use an own macro but until now I
didn't get #pragma work when placed itself inside a macro.

Thanks in advance.

Torsten



Fri, 19 Dec 2003 14:05:17 GMT  
 VC++: how to place a "positioned" #pragma message?

Quote:
>I use #pragma message very often to mark something in my sources I must
>further work on. Now I have two problems:

>1) There seems to be no possibility to give the generated message a position
>information like a compiler error or a warning. I did some experiments with
>__FILE__ and __LINE__

Torsten,

Here's some macros originally from Jeff Richter's Advanced Windows
book:

#define STR(x) #x
#define STR2(x) STR(x)
#define TODO(desc) message(__FILE__ "(" STR2(__LINE__) "): " #desc)

Use them like this:

#pragma TODO(remember to clean this up later on...)

Dave
--
MVP VC++ FAQ: http://www.mvps.org/vcfaq
My address is altered to discourage junk mail.
Please post responses to the newsgroup thread,
there's no need for follow-up email copies.



Fri, 19 Dec 2003 14:31:04 GMT  
 VC++: how to place a "positioned" #pragma message?

Quote:

> I use #pragma message very often to mark something in my sources I must
> further work on. Now I have two problems:

> 1) There seems to be no possibility to give the generated message a position
> information like a compiler error or a warning. I did some experiments with
> __FILE__ and __LINE__:

> #pragma message(__FILE__ "(" __LINE__ "): " "... this is the message")

> This would be successful if __LINE__ could be expanded as text, but in
> reality is becomes an integer number which could not be appended to the
> string coming from __FILE__. I read the documentations about preprocessor
> statements but didn't get much more clever. How to concat __FILE__ and
> __LINE__ to get something like "filename(linenum)" ?

> 2) I want to shorten typing this #pragma, especially if it contains
> complicated macro constructs. I want to use an own macro but until now I
> didn't get #pragma work when placed itself inside a macro.

I copied this code from another posting, I think in this group.  I
didn't record from whom I copied it, so unfortunately I can't give
proper credit.

#define    STR1(x)    #x
#define    STR2(x)    STR1(x)

#define WARNING(x) message(__FILE__ "(" STR2(__LINE__) ") : warning : "
x)
#pragma WARNING("Finish Code")



Fri, 19 Dec 2003 22:19:34 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. VC++: how to place a "positioned" #pragma message?

2. Portable replacement for "#pragma message"

3. Etymology of "pragma"?

4. Meaning of "pragma"

5. #pragma and "Comments" in .obj

6. #pragma data_seg(".shared")

7. any place download "ATL internals"?

8. Your "position" post

9. vc++ equivalent to "dir"

10. Whats " pragma comment(lib, "MyLibrary")" used for

11. remove() vrs fopen("""w")

12. Displaying binary data as ascii "1"'s and "0"'s

 

 
Powered by phpBB® Forum Software