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

I repeated your steps
$ h2xs -Afn Mytest Defaulting to backwards compatibility with perl 5.10.1 If you intend this module to be compatible with earlier perl versions, + please specify a minimum perl version with the -b option. Writing Mytest/ppport.h Writing Mytest/lib/Mytest.pm Writing Mytest/Mytest.xs Writing Mytest/Makefile.PL Writing Mytest/README Writing Mytest/t/Mytest.t Writing Mytest/Changes Writing Mytest/MANIFEST $ copy test.c Mytest 1 file(s) copied. $ copy test.h Mytest 1 file(s) copied. $ h2xs -Oxan Mytest test.h Defaulting to backwards compatibility with perl 5.10.1 If you intend this module to be compatible with earlier perl versions, + please specify a minimum perl version with the -b option. Overwriting existing Mytest!!! Writing Mytest/ppport.h Scanning typemaps... Scanning c:\perl\5.10.1\lib/ExtUtils/typemap Scanning test.h for functions... Scanning test.h for typedefs... Writing Mytest/lib/Mytest.pm Writing Mytest/Mytest.xs Writing Mytest/fallback/const-c.inc Writing Mytest/fallback/const-xs.inc Writing Mytest/Makefile.PL Writing Mytest/README Writing Mytest/t/Mytest.t Writing Mytest/Changes Writing Mytest/MANIFEST $ cd Mytest $ perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Mytest $ dmake test cp lib/Mytest.pm blib\lib\Mytest.pm AutoSplitting blib\lib\Mytest.pm (blib\lib\auto\Mytest) C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.exe C:\perl\5.10.1\li +b\ExtUtils\xsubpp -typemap C:\perl\5.10.1\lib\ExtUtils\typemap Myte +st.xs > Mytest.xsc && C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\per +l.exe -MExtUtils::Command -e "mv" -- Mytest.xsc Mytest.c Please specify prototyping behavior for Mytest.xs (see perlxs manual) 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:\perl\5.10.1\lib\MSWin32-x86-multi-thread\CORE" Mytest. +c 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:\perl\5.10.1\lib\MSWin32-x86-multi-thread\CORE" test.c Running Mkbootstrap for Mytest () C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.exe -MExtUtils::Comma +nd -e "chmod" -- 644 Mytest.bs C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.exe -MExtUtils::Mksym +lists \ -e "Mksymlists('NAME'=>\"Mytest\", 'DLBASE' => 'Mytest', 'DL_FUNC +S' => { }, 'FUNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);" dlltool --def Mytest.def --output-exp dll.exp g++ -o blib\arch\auto\Mytest\Mytest.dll -Wl,--base-file -Wl,dll.base - +mdll -s -L"c:\perl\5.10.1\lib\MSWin32-x86-multi-thread\CORE" -L"C:\Mi +nGW\lib" Mytest.o test.o -Wl,--image-base,0x3e0d0000 C:\perl\5.10 +.1\lib\MSWin32-x86-multi-thread\CORE\libperl510.a -lmoldname -lkernel +32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole3 +2 -loleaut32 -lnetapi32 -luuid -lws2_32 -lmpr -lwinmm -lversion -lodb +c32 -lodbccp32 dll.exp dlltool --def Mytest.def --base-file dll.base --output-exp dll.exp g++ -o blib\arch\auto\Mytest\Mytest.dll -mdll -s -L"c:\perl\5.10.1\lib +\MSWin32-x86-multi-thread\CORE" -L"C:\MinGW\lib" Mytest.o tes +t.o -Wl,--image-base,0x3e0d0000 C:\perl\5.10.1\lib\MSWin32-x86-multi +-thread\CORE\libperl510.a -lmoldname -lkernel32 -luser32 -lgdi32 -lwi +nspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 +-luuid -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 dll.exp C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.exe -MExtUtils::Comma +nd -e "chmod" -- 755 blib\arch\auto\Mytest\Mytest.dll C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.exe -MExtUtils::Comma +nd -e "cp" -- Mytest.bs blib\arch\auto\Mytest\Mytest.bs C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.exe -MExtUtils::Comma +nd -e "chmod" -- 644 blib\arch\auto\Mytest\Mytest.bs C:\perl\5.10.1\bin\MSWin32-x86-multi-thread\perl.exe "-MExtUtils::Comm +and::MM" "-e" "test_harness(0, 'blib\lib', 'blib\arch')" t/*.t t/Mytest.t .. ok All tests successful. Files=1, Tests=2, 0 wallclock secs ( 0.02 usr + 0.03 sys = 0.05 CPU +) Result: PASS
I think you should update your toolchain and your test files (which don't seem to match).
$ pmvers Devel::PPPort ExtUtils::Constant ExtUtils::MakeMaker ExtUtils +::ParseXS C::Scan Devel::PPPort: 3.19 ExtUtils::Constant: 0.22 ExtUtils::MakeMaker: 6.56 ExtUtils::ParseXS: 2.2205 C::Scan: 0.74
h2xs.PL

Replies are listed 'Best First'.
Re^2: How convert header file to XS by h2xs?
by xiaoyafeng (Deacon) on Mar 19, 2010 at 08:11 UTC
    I upgrade all modules you list, but nothing change.I guess whether C file or header file has some problem so that ./test.h:1: error: syntax error before "int" happened.




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

      Examine Mytest.xs and Mytest.c