[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: System includes
From: |
Wayne Scott |
Subject: |
Re: System includes |
Date: |
Wed, 16 Jan 2002 08:42:26 -0500 (EST) |
From: address@hidden
> I've been trying cons again (the latest version of ActivePerl
> contains Digest::MD5 by default, so I can finally use cons on
> Windows at work) and I hit trouble: for the purpose of
> dependency analysis, cons doesn't consider "system" includes
I haven't been using the latest cons, but earlier versions
always handled angle bracket includes.
Look at this function from the package scan::cpp.
# Scan the specified file for include lines.
sub scan {
my($self, $file) = @_;
my($angles, $quotes);
if (exists $file->{angles}) {
$angles = $file->{angles};
$quotes = $file->{quotes};
} else {
my(@anglenames, @quotenames);
return () unless open(SCAN, $file->rpath);
while (<SCAN>) {
next unless /^\s*#/;
if (/^\s*#\s*include\s*([<"])(.*?)[>"]/) {
if ($1 eq "<") {
push(@anglenames, $2);
} else {
push(@quotenames, $2);
}
}
}
close(SCAN);
$angles = $file->{angles} = address@hidden;
$quotes = $file->{quotes} = address@hidden;
}
my(@shortpath) = @{$self->{path}}; # path for <> style includes
my(@longpath) = ($file->{dir}, @shortpath); # path for "" style includes
my(@includes);
for $name (@$angles) {
for $dir (@shortpath) {
my($include) = $dir->lookup_accessible($name);
if ($include) {
push(@includes, $include) unless $include->ignore;
last;
}
}
}
for $name (@$quotes) {
for $dir(@longpath) {
my($include) = $dir->lookup_accessible($name);
if ($include) {
push(@includes, $include) unless $include->ignore;
last;
}
}
}
return @includes
}
It includes both types of includes and understands how the search
paths are different for the two. Now one thing about this scanner, it
can't be sure every #include it finds is real. It doesn't do a full
CPP parse. So if the file is not found when it is searched, then it
is ignored.
Ah! I see the problem. cons doesn't include any search directories
by default. So when it finds:
#include <stdio.h>
It will be ignored because it doesn't know to look in /usr/include to
find it. (unix right?)
So add /usr/include to your CPPPATH in the enviroment and things will
start working. It will pass an extra -I/usr/include to the compile,
but that shouldn't hurt anything.
Does that help?
-Wayne