Front page | perl.perl5.porters |
Postings from April 2003
[perl #21887] h2xs addings enums to exported constants
Thread Next
From:
perlbug-followup
Date:
April 8, 2003 13:01
Subject:
[perl #21887] h2xs addings enums to exported constants
Message ID:
rt-21887-54654.2.82325781862667@bugs6.perl.org
# New Ticket Created by tassilo.parseval@post.rwth-aachen.de
# Please include the string: [perl #21887]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=21887 >
This is a bug report for perl from tassilo.parseval@post.rwth-aachen.de,
generated with the help of perlbug 1.34 running under perl v5.8.0.
-----------------------------------------------------------------
[Please enter your report here]
h2xs (when given a C header) makes constants that are introduced via #defines
in the header exportable. This is fine and very convenient. However, right now
I am dealing with a C library that has a lot of essential constants defined not
via the C preprocessor but through "enum", for instance:
enum aa_attribute {
AA_NORMAL=0,
AA_DIM=1,
AA_BOLD=2,
AA_BOLDFONT=3,
AA_REVERSE=4,
AA_SPECIAL=5
};
As it happens for this library (and others perhaps as well, I would guess),
those enumed constants are the very ones I need all the time. Is there a chance
that h2xs can include constants from enumerations in its export routines?
Currently my work-around is pretty cludgy: I created an XSUB that returns these
constants and have this oddity now in the .pm file:
bootstrap AALib $VERSION;
eval <<EOEVAL;
use constant {
AA_NORMAL => AALib::_get_attribute("AA_NORMAL"),
AA_DIM => AALib::_get_attribute("AA_DIM"),
AA_BOLD => AALib::_get_attribute("AA_BOLD"),
AA_BOLDFONT => AALib::_get_attribute("AA_BOLDFONT"),
AA_REVERSE => AALib::_get_attribute("AA_REVERSE"),
AA_SPECIAL => AALib::_get_attribute("AA_SPECIAL"),
};
EOEVAL
This is ugly and looks rather flaky to me. But creating an XSUB to return the
value of these constants is the only way to reliably export them without
handcoding their values in Perl.
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=utilities
severity=wishlist
---
Site configuration information for perl v5.8.0:
Configured by root at Tue Feb 25 16:06:57 Local time zone must be set--see zic manual page 2003.
Summary of my perl5 (revision 5.0 version 8 subversion 0) configuration:
Platform:
osname=linux, osvers=2.4.20, archname=i686-linux
uname='linux ethan 2.4.20 #2 mon dec 2 14:26:23 cet 2002 i686 unknown '
config_args='-ds -e -Dprefix=/usr -Dccflags= -O3 -march=athlon'
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-O3 -march=athlon -fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-O3 -march=athlon -fno-strict-aliasing'
ccversion='', gccversion='3.2', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldl -lm -lc -lcrypt -lutil
perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil
libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.0:
/usr/lib/perl5/5.8.0/i686-linux
/usr/lib/perl5/5.8.0
/usr/lib/perl5/site_perl/5.8.0/i686-linux
/usr/lib/perl5/site_perl/5.8.0
/usr/lib/perl5/site_perl
.
---
Environment for perl v5.8.0:
HOME=/home/ethan
LANG=C
LANGUAGE (unset)
LC_CTYPE=de_DE@euro
LD_LIBRARY_PATH=:/usr/local/j2sdk1.4.0/jre/lib/i386:/usr/local/pwlib/lib
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/local/j2re1.4.1/bin
PERLDOC_PAGER=/bin/less -isR
PERL_BADLANG (unset)
SHELL=/bin/bash
Thread Next
-
[perl #21887] h2xs addings enums to exported constants
by perlbug-followup