• C

How to create a compile-time warning in Visual C/C++ v6.0

I have a number of unfinished sections of code that need to be fixed.  I want to use the standard C preprocessor "#warning" as a means of keeping track of which sections of code still need to be updated when I compile.

The problem is that from all I can tell, VC6 does not support to preprocessor directive of #warning.  It only supports the directive #error.

Can anyone think of a way to achieve this so my compiles will have the following types of messages displayed along with a comment:

Source.cpp(2871): warning: Old code section needs redesign
Tim TitusCTOAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tim TitusCTOAuthor Commented:
Note: It does not have to be a "warning".  It can show up as a comment or other identification during compile, but it should not halt compiling.
0
phoffricCommented:
I found some suggestions here for this non-portable issue:

"Once defined, use like so:
    #pragma message(Reminder "Fix this problem!")
This will create output like:
    C:\Source\Project\main.cpp(47): Reminder: Fix this problem!"

      http://www.highprogrammer.com/alan/windev/visualstudio.html

Also, some suggestions here:
     http://stackoverflow.com/questions/471935/user-warnings-on-msvc-and-gcc

0
phoffricCommented:
And from MSDN:
// collisions.h
#define __STR2__(x) #x
#define __STR1__(x) __STR2__(x)
#define __LOC__ __FILE__ "("__STR1__(__LINE__)") : Warning Msg: "

// collisions.cpp
#pragma message(__LOC__"Need to do 3D collision testing")

Open in new window

"For additional information concerning the #pragma message directive, see the Visual C++ Help file; Search on: "message (pragma directive)."
    http://support.microsoft.com/kb/155196
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.