This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix .gitignore: only ignore 'perl' in root of repo, not U/perl subdir
[metaconfig.git] / U / perl / Hasfield_t.U
1 ?RCS: Copyright (c) 2016 Dagfinn Ilmari MannsÃ¥ker & H.Merijn Brand
2 ?RCS:
3 ?RCS: You may distribute under the terms of either the GNU General Public
4 ?RCS: License or the Artistic License, as specified in the README file.
5 ?RCS:
6 ?X:
7 ?X: This unit produces a variable that is intended to be eval'ed in
8 ?X: order to define/undefine a symbol. A consistency check is made
9 ?X: regarding any previous value and a warning is issued if there
10 ?X: is any discrepancy.
11 ?X:
12 ?X: To use it, say:
13 ?X:     set d_siginfo_si_errno siginfo_t int si_errno $d_sigaction signal.h
14 ?X:     eval $hasfield_t;
15 ?X:
16 ?MAKE:Hasfield_t: test Compile rm_try Setvar
17 ?MAKE:  -pick add $@ %<
18 ?LINT:define hasfield_t
19 ?S:hasfield_t:
20 ?S:     Internal macro for Configure
21 ?S:.
22 ?V:hasfield_t:
23 ?T:varname struct type field
24 : Define hasfield_t macro for Configure internal use
25 hasfield_t='varname=$1; struct=$2; type=$3; field=$4; shift; shift; shift; shift;
26 while $test $# -ge 2; do
27     case "$1" in
28         $define) echo "#include <$2>";;
29     esac ;
30     shift 2;
31 done > try.c;
32 echo "int main () { $struct foo; $type bar = foo.$field; }" >> try.c;
33 set try;
34 if eval $compile; then
35         val="$define";
36 else
37         val="$undef";
38 fi;
39 set $varname;
40 eval $setvar;
41 $rm_try'
42