Re: Utility to ensure appropriate headers were included
- From: Harald van Dijk <truedfx@xxxxxxxxx>
- Date: Sun, 24 Feb 2008 15:11:13 +0100
On Sun, 24 Feb 2008 04:02:31 -0800, Tomás Ó hÉilidhe wrote:
Recently, there was a Linux program distributed as source code, and it
compiled fine on the majority of systems. However on some systems, it
failed to compile. On some of these systems, people were getting errors
for undeclared tokens, while others were getting linking errors.
Anyway, the problem was that one of the source files was missing:
#include <stdio.h>
This wasn't a problem on most systems because some of the other header
files that were included actually included stdio.h.
Is there any utility out there that will process a source file and
notify you if you're depending on a declaration that isn't present in a
header file that's included directly in the source file?
What exactly do you mean?
a.c:
#include <stdio.h>
int myputchar(char c) { return putchar(c); }
b.c:
#include "b.h"
int myputchar(char c) { return putchar(c); }
b.h:
#include <stdio.h>
c.c:
#include <curses.h>
int myputchar(char c) { return putchar(c); }
For which files do you want a notification? I'm guessing you want none for
a, and one for c. I don't know about b. However, what if <stdio.h> doesn't
define putchar, but instead includes a non-standard header which does? On
such a system (mine happens to declare putchar in <stdio.h> and define it
in <bits/stdio.h>, but the problem does exist for several other standard
library headers) there's really no difference between a and c that any
tool could tell without special built-in knowledge. So what do you want
the tool to do?
.
- References:
- Utility to ensure appropriate headers were included
- From: Tomás Ó hÉilidhe
- Utility to ensure appropriate headers were included
- Prev by Date: Re: Converting unsigned long to string in C
- Next by Date: Re: Converting unsigned long to string in C
- Previous by thread: Re: Utility to ensure appropriate headers were included
- Next by thread: Re: Utility to ensure appropriate headers were included
- Index(es):
Relevant Pages
|
Loading