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

http://www.manning.com/jenness/ExtEmbPerlSrc_v0_90.tar.gz
I'm trying to compile chap6\6.8.1 on win32 ActivePerl 5.6.1.
I modify Makefile.PL to have CCFLAGS => '-TP', and I remove the LD/CC options.
Here's how it goes
E:\dev\XS\ExtEmbPerlSrc_v0_90\chap6\6.8.1>perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Coordinate E:\dev\XS\ExtEmbPerlSrc_v0_90\chap6\6.8.1>nmake Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. cp PerlCoordinate.pm blib\lib\PerlCoordinate.pm cp Coordinate.pm blib\lib\Coordinate.pm C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils/xsubpp -typemap C:\ +Perl\lib\ExtUtils\typemap -typemap typemap Coordinate.xs > Coordinat +e .xsc && C:\Perl\bin\perl.exe -MExtUtils::Command -e mv Coordinate.xsc +Coordinate.c Please specify prototyping behavior for Coordinate.xs (see perlxs manu +al) cl -c -TP -O1 -MD -DNDEBUG -DVERSION=\"0.01\" -DXS_VERS +ION=\"0.01\" "-IC:\Perl\lib\CORE" Coordinate.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for +80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. Coordinate.c C:\Perl\lib\CORE\dosish.h(111) : warning C4005: 'Stat' : macro redefin +ition C:\Perl\lib\CORE\win32.h(306) : see previous definition of 'St +at' C:\Perl\lib\CORE\perl.h(1748) : error C2146: syntax error : missing '; +' before identifier 'perl_os_thread' C:\Perl\lib\CORE\perl.h(1748) : fatal error C1004: unexpected end of f +ile found NMAKE : fatal error U1077: 'cl' : return code '0x2' Stop.
-TP means treat all files as c++ files. If I try -Tp Coordinate.c it will treat Coordinate.c as a c++ file. So I try the following manually
cl -c -nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_D +ES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_R +EADFIX -O1 -MD -DNDEBUG -DVERSION=\"0.01\" -DXS_VERSION=\"0.01\" + "-IC:\Perl\lib\CORE" -Tp Coordinate.c
and am faced with
C:\PROGRA~1\MICROS~3\VC98\INCLUDE\math.h(514) : error C2894: templates + cannot be declared to have 'C' linkage C:\PROGRA~1\MICROS~3\VC98\INCLUDE\streamb.h(89) : error C2059: syntax +error : '(' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\streamb.h(89) : error C2143: syntax +error : missing ',' before '->' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\streamb.h(89) : error C2501: 'Perl_I +StdIO_ptr' : missing storage-class or type specifiers C:\PROGRA~1\MICROS~3\VC98\INCLUDE\streamb.h(89) : error C2059: syntax +error : '->' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\istream.h(108) : warning C4003: not +enough actual parameters for macro 'PerlLIO_read' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\istream.h(109) : warning C4003: not +enough actual parameters for macro 'PerlLIO_read' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\istream.h(110) : warning C4003: not +enough actual parameters for macro 'PerlLIO_read' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\istream.h(161) : warning C4003: not +enough actual parameters for macro 'PerlLIO_read' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\istream.h(161) : warning C4003: not +enough actual parameters for macro 'PerlLIO_read' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\istream.h(162) : warning C4003: not +enough actual parameters for macro 'PerlLIO_read' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\istream.h(162) : warning C4003: not +enough actual parameters for macro 'PerlLIO_read' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\ostream.h(91) : warning C4003: not e +nough actual parameters for macro 'PerlLIO_write' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\ostream.h(92) : warning C4003: not e +nough actual parameters for macro 'PerlLIO_write' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\ostream.h(93) : warning C4003: not e +nough actual parameters for macro 'PerlLIO_write' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\ostream.h(126) : warning C4003: not +enough actual parameters for macro 'PerlLIO_write' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\ostream.h(126) : warning C4003: not +enough actual parameters for macro 'PerlLIO_write' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\ostream.h(127) : warning C4003: not +enough actual parameters for macro 'PerlLIO_write' C:\PROGRA~1\MICROS~3\VC98\INCLUDE\ostream.h(127) : warning C4003: not +enough actual parameters for macro 'PerlLIO_write' Coordinate.c(276) : fatal error C1004: unexpected end of file found
What do I do now? (ps: the book is back at the library ;()
Adding #include <math.h> and compiling manually (nomake) I get rid of the math.h related error, but the rest remain.
keep in mind this do compile on linux(debian).

btw, with perl5.8.0 the story is

Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. cp Coordinate.pm blib\lib\Coordinate.pm cp PerlCoordinate.pm blib\lib\PerlCoordinate.pm G:\Perl\bin\perl.exe G:\Perl\lib\ExtUtils/xsubpp -typemap G:\ +Perl\lib\ExtUtils\typemap -typemap typemap Coordinate.xs > Coordinat +e .xsc && G:\Perl\bin\perl.exe -MExtUtils::Command -e mv Coordinate.xsc +Coordinate.c Please specify prototyping behavior for Coordinate.xs (see perlxs manu +al) cl -c -TP -MD -DNDEBUG -O1 -DVERSION=\"0.01\" -DXS_VERS +ION=\"0.01\" "-IG:\Perl\lib\CORE" Coordinate.c Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 12.00.8804 for +80x86 Copyright (C) Microsoft Corp 1984-1998. All rights reserved. Coordinate.c G:\Perl\lib\CORE\win32.h(313) : error C2061: syntax error : identifier + 'Stat_t' G:\Perl\lib\CORE\win32.h(412) : error C2143: syntax error : missing ', +' before '*' G:\Perl\lib\CORE\win32.h(412) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(104) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(104) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(105) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(105) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(107) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(107) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(109) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(109) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(110) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(110) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(205) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(205) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(218) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(218) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(330) : error C2061: syntax error : identifie +r 'SV' G:\Perl\lib\CORE\perlio.h(333) : error C2061: syntax error : identifie +r 'SV' G:\Perl\lib\CORE\perlio.h(336) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(336) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(345) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(345) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(349) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(349) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(356) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(356) : error C2059: syntax error : '*' G:\Perl\lib\CORE\perlio.h(361) : error C2143: syntax error : missing ' +,' before '*' G:\Perl\lib\CORE\perlio.h(361) : error C2059: syntax error : '*' G:\Perl\lib\CORE\win32iop.h(72) : error C2061: syntax error : identifi +er 'Stat_t' G:\Perl\lib\CORE\win32iop.h(73) : error C2061: syntax error : identifi +er 'Stat_t' G:\Perl\lib\CORE\win32iop.h(76) : error C2061: syntax error : identifi +er 'IV' G:\Perl\lib\CORE\win32iop.h(132) : error C2061: syntax error : identif +ier 'Stat_t' G:\Perl\lib\CORE\dosish.h(130) : warning C4005: 'Stat' : macro redefin +ition G:\Perl\lib\CORE\win32.h(274) : see previous definition of 'St +at' G:\Perl\lib\CORE\perl.h(2002) : error C2146: syntax error : missing '; +' before identifier 'perl_os_thread' G:\Perl\lib\CORE\perl.h(2002) : fatal error C1004: unexpected end of f +ile found NMAKE : fatal error U1077: 'cl' : return code '0x2' Stop.
On a side note (relating to perlxs and c++) I have written an extension for wxperl (all c++, Wx-DialUpManager-0.01.tar.gz -- compiles fine, but not the final version DialUpManager), but it doesn't use iostream (and usually, neither does wxwindows).


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: perlxs and c++ : dosish.h(111) : warning C4005: 'Stat' : macro redefinition
by PodMaster (Abbot) on Jul 14, 2003 at 17:13 UTC
    It took a bit of a break from xs for (been pythonging among other things),
    
    I took some advice from Mattia,
    and got it to compile by adding
    
       DEFINE => ' -TP ',
    
    instead of 
    
       CCFLAGS => '-TP',
    
    along with moving the c++ includes before the perl includes
    
       #include <stdio.h>
       #include <iostream.h>
       #include <stdlib.h>
    
    and adding
       #include <math.h>
    to the list.
    
    Here's how it goes:
    E:\dev\XS\ExtEmbPerlSrc_v0_90\chap6\6.8.1>perl Makefile.PL Checking if your kit is complete... Looks good Writing Makefile for Coordinate E:\dev\XS\ExtEmbPerlSrc_v0_90\chap6\6.8.1>nmake Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. cp PerlCoordinate.pm blib\lib\PerlCoordinate.pm cp Coordinate.pm blib\lib\Coordinate.pm C:\Perl\bin\perl.exe C:\Perl\lib\ExtUtils/xsubpp -typemap C:\ +Perl\lib\ExtUtils\typemap -typemap typemap Coordinate.xs > Coordinat +e .xsc && C:\Perl\bin\perl.exe -MExtUtils::Command -e mv Coordinate.xsc +Coordinate.c Please specify prototyping behavior for Coordinate.xs (see perlxs manu +al) cl -c -nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRI +CT -DHAVE_DES_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPE +R L_MSVCRT_READFIX -O1 -MD -DNDEBUG -DVERSION=\"0.01\" -DXS_VERSION= +\"0.01\" "-IC:\Perl\lib\CORE" -TP Coordinate.c Coordinate.c Running Mkbootstrap for Coordinate () C:\Perl\bin\perl.exe -MExtUtils::Command -e chmod 644 Coordina +te.bs C:\Perl\bin\perl.exe -MExtUtils::Mksymlists -e "Mksymlists('N +AME'=>\"Coordinate\", 'DLBASE' => 'Coordinate', 'DL_FUNCS' => { }, ' +F UNCLIST' => [], 'IMPORTS' => { }, 'DL_VARS' => []);" link -out:blib\arch\auto\Coordinate\Coordinate.dll -dll -nolog +o -nodefaultlib -release -libpath:"C:/Perl\lib\CORE" -machine:x86 C +o ordinate.obj C:\Perl\lib\CORE\perl56.lib oldnames.lib kernel32.lib u +ser32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.l +i b ole32.lib oleaut32.lib netapi32.lib uuid.lib wsock32.lib mpr.lib wi +nmm.lib version.lib odbc32.lib odbccp32.lib msvcrt.lib -def:Coordina +t e.def Creating library blib\arch\auto\Coordinate\Coordinate.lib and objec +t blib\arch\auto\Coordinate\Coordinate.exp C:\Perl\bin\perl.exe -MExtUtils::Command -e chmod 755 blib\arc +h\auto\Coordinate\Coordinate.dll C:\Perl\bin\perl.exe -MExtUtils::Command -e cp Coordinate.bs b +lib\arch\auto\Coordinate\Coordinate.bs C:\Perl\bin\perl.exe -MExtUtils::Command -e chmod 644 blib\arc +h\auto\Coordinate\Coordinate.bs E:\dev\XS\ExtEmbPerlSrc_v0_90\chap6\6.8.1>nmake test Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. C:\Perl\bin\perl.exe "-Iblib\lib" "-Iblib\arch" test.pl 1..6 # Running under perl version 5.006001 for MSWin32 # Win32::BuildNumber 633 # Current time local: Mon Jul 14 10:10:26 2003 # Current time GMT: Mon Jul 14 17:10:26 2003 # Using Test.pm version 1.24 # C is CoordinatePtr=SCALAR(0x1abf138) ok 1 ok 2 ok 3 ok 4 ok 5 ok 6 E:\dev\XS\ExtEmbPerlSrc_v0_90\chap6\6.8.1>

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Re: perlxs and c++ : dosish.h(111) : warning C4005: 'Stat' : macro redefinition (debug)
by tye (Sage) on Apr 28, 2003 at 16:09 UTC

    You are getting an error about Stat being redefined but I don't see any mention of you looking at the definitions of Stat. I did a quick look and found that the one in win32.h goes like this:

    #undef Stat #define Stat win32_stat
    so it appears that win32.h expects to be included after dosish.h.

    So I'd investigate why they are being included in the wrong order.

    All copies of perl.h that I have handy only mention perl_os_thread in lines like

    typedef pthread_t perl_os_thread;
    and typedef is a reserved word in C so I don't see how you could get that error unless pthread_t is #defined to be something that at least contains whitespace. You might want to use -E (or whatever) to see what output the C preprocessor is producing.

                    - tye
      I have seen that, but didn't conclude that "so it appears that win32.h expects to be included after dosish.h.".

      From what I can gather by examining perl.h , it is being included after.

      Thats still my impression after inspecing Compress.i (produced by -P with -C). You can get it at http://crazyinsomniac.perlmonk.org/perl/misc/Coordinate.i.bz2 if you wanna take a peek.

      So I looked up C2146 and ran into C2065 (missed it before), and under MSDN, some of the more notable tips were

      Make sure any include file containing the required declaration is not omitted.

      Make sure you are including any necessary header files if you have defined VC_EXTRALEAN, WIN32_LEAN_AND_MEAN, or WIN32_EXTRA_LEAN. Defining these symbols excludes some functionality (certain header files are excluded) from windows.h and afxv_w32.h (for MFC applications) to speed compiles. Search windows.h and afxv_w32.h for these symbols for the most up-to-date description of what is excluded.

      win32.h does define WIN32_LEAN_AND_MEAN. And WINDOWS.H does have
      #ifndef WIN32_LEAN_AND_MEAN #include <cderr.h> #include <dde.h> #include <ddeml.h> #include <dlgs.h> #ifndef _MAC #include <lzexpand.h> #include <mmsystem.h> #include <nb30.h> #include <rpc.h> #endif #include <shellapi.h> #ifndef _MAC #include <winperf.h> #if(_WIN32_WINNT >= 0x0400) #include <winsock2.h> #include <mswsock.h> #else #include <winsock.h> #endif /* _WIN32_WINNT >= 0x0400 */ #endif #ifndef NOCRYPT #include <wincrypt.h> #endif #ifndef NOGDI #include <commdlg.h> #ifndef _MAC #include <winspool.h> #ifdef INC_OLE1 #include <ole.h> #else #include <ole2.h> #endif /* !INC_OLE1 */ #endif /* !MAC */ #endif /* !NOGDI */ #endif /* WIN32_LEAN_AND_MEAN */
      But this is largely a dead end.

      update: I have also posted this as a question over at the Extending And Embedding forum as Compiling ExtEmbPerlSrc_v0_90/chap6/6.8.1 on Win32 in hopes the authors will be able to help out.

      Maybe later (if i don't figure it out) i'll inquire on one of the mailing lists as well (maybe p5p).


      MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
      I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
      ** The Third rule of perl club is a statement of fact: pod is sexy.