blue_cowdawg has asked for the wisdom of the Perl Monks concerning the following question:

I have a header file such that:

#include "mysql/mysql.h" typedef struct DataLib { MYSQL mysql; char *host; char *dbname; char *user; char *password; } DataLib; typedef DataLib *pDataLib; int connect2DB(char *host,char *dbname,char *user,char *password); int startQuery(char *sql); char **getRow(void);
When I invoke h2xs as such:
h2xs -xmas -nDataLib DataLib.h
when this happened:
h2xs -xmas -nDataLib DataLib.h Defaulting to backwards compatibility with perl 5.8.0 If you intend this module to be compatible with earlier perl versions, + please specify a minimum perl version with the -b option. Writing DataLib/ppport.h Scanning typemaps... Scanning /usr/lib/perl5/5.8.0/ExtUtils/typemap Scanning DataLib.h for functions... Expecting parenth after identifier in `fd_set *__restrict __readfds' after `fd_set *__restrict ' at /usr/lib/perl5/site_perl/5.8.0/C/Scan.p +m line 797.
Have I found a new way to break h2xs? The C::Scan on my system is whatever the latest from CPAN is...


Peter L. Berghold -- Unix Professional
Peter at Berghold dot Net
   Dog trainer, dog agility exhibitor, brewer of fine Belgian style ales. Happiness is a warm, tired, contented dog curled up at your side and a good Belgian ale in your chalice.

Replies are listed 'Best First'.
Re: h2xs wierdness... what the????
by mpeppler (Vicar) on Sep 09, 2003 at 23:46 UTC
    I rather think that you've found a bug with C::Scan. Here's what appears to be the problem (at least on my linux box:)
    typedef __fd_mask fd_mask; # 102 "/usr/include/sys/select.h" 3 extern int select (int __nfds, fd_set *__restrict __readfds, fd_set *__restrict __writefds, fd_set *__restrict __exceptfds, struct timeval *__restrict __timeout) ; # 216 "/usr/include/sys/types.h" 2 3
    The above is the result of running cc -E on your DataLib.h file. It would appear that C::Scan doesn't understand __restrict as a keyword.

    You might get decent results without using the -x option to h2xs as a work-around.

    Michael

Re: h2xs wierdness... what the????
by Roger (Parson) on Sep 10, 2003 at 00:23 UTC
    This error has due to a bug in the Compiler's parser. It has been know for a few years now. Consider the following:
    1) int *__restrict n; 2) fd_set *__restrict m;
    The first one will be compiled ok, but the second one will fail. Because when compiler sees fd_set, it takes it as a data type, and then it assumes the next one would be the variable name, which in this case is the __restrict key word.

    I suspect this problem has been subsequently fixed in the gcc compiler, however the C compiler used by perl might be a lite-weight (and perhaps older) version of gcc, which might still exhibit incorrect behaviour on __restrict.