h2xs -Oxan ... fails when processing GNU/Linux /usr/include/stdio.h

F

freeholder

I'm attempting to build a module created by an associate that works
fine on a Solaris 9 system. This is not going to actually be packaged
up in any way for distribution, it's for internal use on a few systems,
so we've chosen to simply build the module from scratch for the two
environments. This may not be the best decision, but that's where we
are now.

The problem is that the files and process used successfully on the
Solaris system fail in the second run of h2xs on the Linux box (both
Red Hat EL and Debian etch), with the following error:

--
$ h2xs -Oxan CLIEXT cliext.h
Defaulting to backwards compatibility with perl 5.8.4
If you intend this module to be compatible with earlier perl versions,
please
specify a minimum perl version with the -b option.

Overwriting existing CLIEXT!!!
Writing CLIEXT/ppport.h
Scanning typemaps...
Scanning /usr/local/perl/lib/5.8.4/ExtUtils/typemap
Scanning cliext.h for functions...
Expecting parenth after identifier in `struct _IO_FILE_plus
_IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;
extern struct _IO_FILE_plus _IO_2_1_stderr_;
# 354 "/usr/include/libio.h" 3 4
typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t
__nbytes);

....deleted blank lines...

typedef __ssize_t __io_write_fn (void *__cookie, __const char *__buf,
size_t __n);

....deleted blank lines...

typedef int __io_seek_fn (void *__cookie, __off64_t *__pos, int __w);


typedef int __io_close_fn (void *__cookie);
# 406 "/usr/include/libio.h" 3 4
extern int __underflow (_IO_FILE *) __attribute__ ((__nothrow__))'
after `struct _IO_FILE_plus _IO_2_1_stdin_' at /usr/local/perl/lib/site
--

Nothing useful is created, of course, and we need to use the stdio.h in
order to get the definition of the FILE pointer type, which is being
passed from the Perl code to the C routine.

I would appreciate any assisstance anyone can provide to solve this.

Thanks,

Bob (freeholder ;)
 
B

Ben Morrow

Quoth "freeholder said:
I'm attempting to build a module created by an associate that works
fine on a Solaris 9 system. This is not going to actually be packaged
up in any way for distribution, it's for internal use on a few systems,
so we've chosen to simply build the module from scratch for the two
environments. This may not be the best decision, but that's where we
are now.

Assuming the header declares the same functions on both systems, why not
just copy the XS file from one to the other, and then port if necessary?

Ben
 
F

freeholder

An excellent idea, which I had tried yesterday evening. There were a
slew of compiler errors, though. But your idea did lead to our
managing to get the thing to compile, by going back to the XS file and
cleaning it up, which is to say we used it as an example and removed
all the extra stuff h2xs had put in, essentially building the XS file
by hand.

This got rid of all the compiler errors and we have an extension that
builds. Unfortunately, it segfaults, but that is not an issue for this
list.

Thanks for the suggestion.

Bob

Ben said:
Quoth "freeholder said:
I'm attempting to build a module created by an associate that works
fine on a Solaris 9 system. This is not going to actually be packaged
up in any way for distribution, it's for internal use on a few systems,
so we've chosen to simply build the module from scratch for the two
environments. This may not be the best decision, but that's where we
are now.

Assuming the header declares the same functions on both systems, why not
just copy the XS file from one to the other, and then port if necessary?

Ben

--
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes, [ Heracles shoots Vulture with arrow. Vulture bursts into ]
'Alcestis') [ flame, and falls out of sight. ] (e-mail address removed)
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
freeholder
$ h2xs -Oxan CLIEXT cliext.h
Defaulting to backwards compatibility with perl 5.8.4
If you intend this module to be compatible with earlier perl versions,
please
specify a minimum perl version with the -b option.

Overwriting existing CLIEXT!!!
Writing CLIEXT/ppport.h
Scanning typemaps...
Scanning /usr/local/perl/lib/5.8.4/ExtUtils/typemap
Scanning cliext.h for functions...
Expecting parenth after identifier in `struct _IO_FILE_plus
_IO_2_1_stdin_;
extern struct _IO_FILE_plus _IO_2_1_stdout_;

You are not supposed to do this. Run h2xs on a file which defines the
API. So replace your cliext.h by

#include <stdio.h>
#include <cliext_api.h>

and run h2xs on cliext_api.h.

Anyway, Perl is not (very) compatible with stdio, so make sure the API
does not use stdio.h; for this, you may need to break cliext_api.h
into more parts, keeping the parts accessible from Perl separate from
parts accessing stdio.

Hope this helps,
Ilya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

#include errors 9
A little light code review requested 2
ERROR: storage size of 'tzp' isn't known 1
Inline C 1
help on python SWIG C++ extension 4
Container Interfaces 17
Observing a container 2
Newbie: Linked list 2

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top