develooper Front page | perl.perl5.porters | Postings from January 2003

Re: [perl #20636] ExtUtils::Constant trying to make empty #defines accessible

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
January 31, 2003 07:53
Subject:
Re: [perl #20636] ExtUtils::Constant trying to make empty #defines accessible
Message ID:
20030131155312.B83537@plum.flirble.org
On Fri, Jan 31, 2003 at 08:02:16AM -0000, tassilo.parseval@post.rwth-aachen.de (via RT) wrote:

> When creating an extension skeleton using
> 
>     h2xs -O -b <version> -n Module::Name header.h
> 
> it appears as though ExtUtils::Constant tries to make symbols exportable
> that are merely #defined but have no value.

> The above problem remains when removing the two offending symbols
> (__BEGIN_DECLS and __END_DECLS) from the NAMES-list in
> ExtUtils::Constant::WriteConstants() in Makefile.PL.


> An excerpt from the header I've been using:
> 
>     #ifndef __MPLIB_H
>     #define __MPLIB_H
>     #undef __BEGIN_DECLS
>     #undef __END_DECLS
>     #ifdef __cplusplus
>     # define __BEGIN_DECLS extern "C" {
>     # define __END_DECLS }
>     #else
>     # define __BEGIN_DECLS /* empty */
>     # define __END_DECLS /* empty */
>     #endif


ExtUtils::Constant is just doing what it's told by h2xs. The real cause
will be some sort of bug in h2xs that thinks that those two macros are
defined. I suspect it's getting it wrong in the code somewhere near here:

    # Remove macros which expand to typedefs
    print "Typedefs are @td.\n" if $opt_d;
    my %td = map {($_, $_)} @td;
    # Add some other possible but meaningless values for macros
    for my $k (qw(char double float int long short unsigned signed void)) {
      $td{"$_$k"} = "$_$k" for ('', 'signed ', 'unsigned ');
    }
    # eval {require 'dumpvar.pl'; ::dumpValue( [\@td, \%td] ); 1} or warn $@;
    my $n = 0;
    my %bad_macs;
    while (keys %td > $n) {
      $n = keys %td;
      my ($k, $v);
      while (($k, $v) = each %seen_define) {
	# print("found '$k'=>'$v'\n"), 
	$bad_macs{$k} = $td{$k} = $td{$v} if exists $td{$v};
      }
    }
    # Now %bad_macs contains names of bad macros
    for my $k (keys %bad_macs) {
      delete $const_names{$prefixless{$k}};
      print "Ignoring macro $k which expands to a typedef name '$bad_macs{$k}'\n" if $opt_d;
    }


Not that I know how to fix it from a superficial look.

Nicholas Clark

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About