in reply to How convert header file to XS by h2xs?

In the Mytest directory can you successfully run:
gcc -c -I. -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE - +DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPER +L_MSVCRT_READFIX -s -O2 -DVERSION=\"0.01\" -DXS_VERSION=\"0 +.01\" "-IC:\strawberry\perl\lib\CORE" test.c
It runs fine for me (based on the test.h and test.c that you provided). If it doesn't work for you, then I suggest that the actual 'test.h' you're using is different to the one you provided in your original post. If, however, it does run fine for you, then try running:
gcc -c -I. -s -O2 -DWIN32 -DHAVE_DES_FCRYPT -DUSE_SITECUSTOMIZE - +DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-strict-aliasing -DPER +L_MSVCRT_READFIX -s -O2 -DVERSION=\"0.01\" -DXS_VERSION=\"0 +.01\" "-IC:\strawberry\perl\lib\CORE" Mytest.c
That's the same as the first command I provided - except that 'test.c' has been replaced by 'Mytest.c'. That's also now the same command that failed for you in your original post - so it should fail again this time in exactly the same way. Does it ?

The point I'm trying to make is that something here just doesn't add up :-)

Cheers,
Rob

Replies are listed 'Best First'.
Re^2: How convert header file to XS by h2xs?
by almut (Canon) on Mar 19, 2010 at 10:32 UTC
    then I suggest that the actual 'test.h' you're using is different to the one you provided

    That's also my interpretation, in particular as the 'syntax error before "int"' in test.h is being reported for line 1... (any error before any of the ints in that file should be on line 2)

    In case compiling test.c (the first command you suggested) should fail, the OP might want to replace option -c in that commandline with -E in order to take a look at the preprocessed output.

Re^2: How convert header file to XS by h2xs?
by Anonymous Monk on Mar 19, 2010 at 12:33 UTC
    The point I'm trying to make is that something here just doesn't add up :-) directly! but I checked Mytest.xs:
    #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "test.h" #include "const-c.inc" MODULE = Mytest PACKAGE = Mytest INCLUDE: const-xs.inc
    I can't find something strange. So, how can I do next? check Mytest.c or fallback directory?
      So, how can I do next?

      As the compiler obviously thinks the error has to do with test.h, it would seem to make sense to focus on that issue.  Could you try what Rob and I suggested above, i.e. simply try to compile test.c alone (which includes test.h) — possibly with option -E to get an idea of what code the compiler is actually trying to compile.

        the first one (test.c) run correctly, the later throw the same error as my original post.

        And I think what Rob mean is checking the difference of test.c and Mytest.c. since I'm new to XS, I cant find something strange.

        Besides, Because the same files could convert to XS successfully on ubuntu, does it mean this problem is only related to Win32 platform? should I report author of h2xs it?




        I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction