473,385 Members | 1,324 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to stop compilation when a header file is missing


Hi!

I have a program that #includes a header file of an external
library.
If the environment is set-up correctly, this file is found in the
include path
and everything works.

Now, assume that a user forgot to either install the external
library
or to add the relevant directory to the include path. Obviously, the
compiler complains about a missing .h file, but then spews out
several screenfuls of error messages, as it does not recognize symbols
brought in by the include file that's missing. By doing this, it
quickly
hides the real error from the user.

Is there any way to have the compiler stop after it notices the
header
file is missing, without mindlessly trying to parse the rest of the
file?
Before I'm sent off to RTFM of the compiler to find the relevant
switch
or pragma, is there a (quasi)-portable way of achieving this through
some clever source code wizardry, regardless of the compiler?
Maybe there's a well-known way to generate an absolutely fatal
compilation error in an #ifndef for a symbol brought in by the header
file that's missing? Is #error C++ or a g++ extension?

TIA,
- J.
Jun 27 '08 #1
1 2045
ja************@gmail.com wrote:
Hi!

I have a program that #includes a header file of an external
library.
If the environment is set-up correctly, this file is found in the
include path
and everything works.

Now, assume that a user forgot to either install the external
library
or to add the relevant directory to the include path. Obviously, the
compiler complains about a missing .h file, but then spews out
several screenfuls of error messages, as it does not recognize symbols
brought in by the include file that's missing. By doing this, it
quickly
hides the real error from the user.
So? It seems a user problem to deal with errors in the orderly
fashion, no?
>
Is there any way to have the compiler stop after it notices the
header
file is missing, without mindlessly trying to parse the rest of the
file?
Before I'm sent off to RTFM of the compiler to find the relevant
switch
or pragma, is there a (quasi)-portable way of achieving this through
some clever source code wizardry, regardless of the compiler?
No.
Maybe there's a well-known way to generate an absolutely fatal
compilation error in an #ifndef for a symbol brought in by the header
file that's missing? Is #error C++ or a g++ extension?
#error is C++. How does that help? Unless your installation is
going to replace some placeholder with the only directive in it...

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Chris Mantoulidis | last post by:
Seperate compilation (that's what it's called, right?) seems to be quite popular, so I decided to get some info about it, and (d'oh) use it... But it's whole structure seems weird to me... ...
11
by: Steven T. Hatton | last post by:
I've made no secret of the fact that I really dislike the C preprocessor in C++. No aspect of the language has caused me more trouble. No aspect of the language has cause more code I've read to be...
1
by: Frankie Montenegro | last post by:
Hi I am trying to understand separate compilation and how to set up simple Makefiles. This is my question: Say I have a simple 'nonmain' sourcefile. Just a couple of functions, not longer than...
4
by: Ced | last post by:
Hi, i'm not an expert in C but i try to compile BTNG software under linux kernel 2.4.2-2. I get these errors at the very first stage. Does someone could have a rapid look on this and tell me...
12
by: wanghz | last post by:
Hi, Could I ask some questions about the conditional compilaion? Suppose I have three simple files: a.c, b.c and c.h /* --------a.c--------- */ #include <stdio.h> #include "c.h" int...
4
by: Senthil | last post by:
I installed the MSXML 4.0 sp2 and wanted to play around with DOM using C++ and followed the instructions on "Program with DOM in C/C++" section in the MSXML SDK. The compilation fails in Visual...
5
by: Mikael S. H. | last post by:
Header file compilation I'm coding a small irc bot, and I've noticed that compilation takes very long when I add certain header files (compared to compilation time without). I've tried to find...
3
by: sam_cit | last post by:
Hi All, I have the following scenario, A class is declared in the header file and has a static member function sample() in sample.h sample.cc uses the static member function sample(). the...
4
by: srini4vasan | last post by:
Hi, I wrote a small socket program in C++ using unix machine. Compiler CC. It is asking some library file or linker file Could you please send the library files or linker files for following...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.