Hi Ron,

The original rendition compiles on Windows ok if the compiler being used is gcc. (I think you said you had tested it on ActivePerl 5.24.0 and found it to be fine.)

However, with my MS compiler (Microsoft (R) C/C++ Optimizing Compiler Version 14.00.40310.41 for AMD64), I got:

########################################
C:\_32\pscrpt\inline>perl try.pl

Microsoft (R) Program Maintenance Utility   Version 7.00.8882
Copyright (C) Microsoft Corp 1988-2000. All rights reserved.

Running Mkbootstrap for try_pl_7dcf ()
"C:\_64\ap1600\bin\perl.exe" -MExtUtils::Command -e chmod -- 644 "try_pl
_7dcf.bs"
"C:\_64\ap1600\bin\perl.exe" C:\_64\ap1600\lib\ExtUtils\xsubpp" -typem ap "C:\_64\ap1600\lib\ExtUtils\typemap" -typemap "C:\_32\pscrpt\inline\typemap" try_pl_7dcf.xs > try_pl_7dcf.xsc && "C:\_64\ap1600\bin\perl.exe" -MExtUtils::Co
mmand -e mv -- try_pl_7dcf.xsc try_pl_7dcf.c
cl -c -I"C:/_32/pscrpt/inline" -nologo -GF -W3 -MD -Zi -DNDEBUG -Ox -G
L -fp:precise -DWIN32 -D_CONSOLE -DNO_STRICT -DWIN64 -DCONSERVATIVE -DPERL_TEXTM
ODE_SCRIPTS -DUSE_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DUS E_PERLIO -std=c99 -MD -Zi -DNDEBUG -Ox -GL -fp:precise -DVERSION=\"0.00\" -D
XS_VERSION=\"0.00\"  "-IC:\_64\ap1600\lib\CORE"   try_pl_7dcf.c
cl : Command line warning D9002 : ignoring unknown option '-std=c99'
try_pl_7dcf.c
try_pl_7dcf.xs(14) : error C2143: syntax error : missing ';' before 'type'
try_pl_7dcf.xs(14) : error C2143: syntax error : missing ';' before 'type'
try_pl_7dcf.xs(14) : error C2143: syntax error : missing ')' before 'type'
try_pl_7dcf.xs(14) : error C2143: syntax error : missing ';' before 'type'
try_pl_7dcf.xs(14) : error C2065: 'ix' : undeclared identifier
try_pl_7dcf.xs(14) : warning C4552: '<' : operator has no effect; expected operator with side-effect
try_pl_7dcf.xs(14) : error C2059: syntax error : ')'
try_pl_7dcf.xs(14) : error C2143: syntax error : missing ';' before '{'
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.

A problem was encountered while attempting to compile and install your Inline
C code. The command that failed was:
 C:\_64\PLATFO~1\Bin\nmake.exe > out.make 2>&1

The build directory was:
C:\_32\pscrpt\inline\_Inline\build\try_pl_7dcf

To debug the problem, cd to the build directory, and inspect the output files.

at try.pl line 0.
       ...propagated at C:/_64/ap1600/site/lib/Inline/C.pm line 772.
INIT failed--call queue aborted.

########################################

Admittedly, that MS compiler is getting a little bit old but my understanding is that even the most recent MS compilers are not C99 compliant (as MS like to make up their own rules).
FAIK there might also be other non C99 compliant compilers in use.

Both ActiveState and StrawberryPerl provide gcc-based perls for Windows, but there are still people using MS compilers with perl on Windows. (I'm not really one of those people - I keep that MS compiler for reference only.)

So I think, for a cookbook especially, it's best to code for the lowest common denominator unless that's impractical - though I'm sure that use of non C99 compliant compilers with perl is the exception rather than the rule.

Cheers,
Rob

-----Original Message----- From: Ron Grunwald via inline
Sent: Friday, December 09, 2016 9:27 AM
To: sisyph...@optusnet.com.au
Cc: inline@perl.org
Subject: Re: Inline::C Cookbook addition

Hi Rob,

So I gather that the example in its original state did not compile on Windows? I would be somewhat surprised that there are still C compilers in use that are not C99 compliant.

Many thanks for your suggestions, and I will follow your advice on using the github process.

Cheers,
Ron.

On 8 Dec 2016, at 3:08 pm, sisyph...@optusnet.com.au wrote:

The "use Inline C => Config => ..." line can be removed if you rewrite the __C__ section as:

__DATA__
__C__
#define N_MP 4

void CalcSurfaceHeights() {
 double x[N_MP], y[N_MP], z;
 int ix;
 char   *mesh_data = SvPV_nolen(get_sv("main::mesh_data", 0));

 sscanf(mesh_data, "MESH-POINTS %lf%lf%lf%lf%lf%lf%lf%lf",
                   x, y, x+1, y+1, x+2, y+2, x+3, y+3);

 for (ix=0; ix < N_MP; ix++) {
    z = 0.5*( sin(x[ix]) + sin(y[ix]) );

    printf("Surface-Height: %6.3f Mesh-Point: %6.2f, %6.2f\n",
           z, x[ix], y[ix]);
 }
}

All I've done is move the declaration of "ix" from the for() loop to the declaration section at the beginning of CalcSurfaceHeights(). This then enables the code to compile using compilers (such as Microsoft compilers) that are not C99-compliant.

This mailing list is very quiet these days and I think your request will probably fall "through the cracks" unless you submit it as a github "Issue" or a github pull request.

Cheers,
Rob

Reply via email to