Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

#pragma for catching errors in C compilers?

Status
Not open for further replies.

Nosferatu

Programmer
Jun 9, 2000
412
0
0
RO
Hello!

I am using MSVC 6.0 and I wonder if there's any way to catch a compiler error during compile time and output a descriptive error text.

What I am trying to do is if a certain header was not included in the project (or not found in the specified path), output a descriptive error message.
What I have now is:

Code:
#include "..\..\..\_XmlToDcm_Lib\Source\IncXmlToDcm.h"

#ifndef XMLTODCM_INCLUDED
#error MMMToDcm FATAL ERROR: XMLToDCM libary Headers must be present! This program cannot be built without XmlToDcm static library
#endif
If the file included is not found, the compilation stops before outputing the error message.
Is there any way I can print that message?
The code works if the "include" statement is commented out, of corse - which has the equivalent effect of not defining XMLTODCM_INCLUDED macro. [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
 
Compiler gives you an error message if # include fails & stops compilation , this should alert the user. # pragma which sets compiler warning levels may not be applicable for this.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top