Hi Rob,

Thank you for testing the example with your compiler, and also thank you for 
the wonderful advice. I will remove the index variable declaration from the for 
loop.

>> for (int ix=0; ix < N_MP; ix++) {

Cheers,
Ron.

> On 9 Dec 2016, at 7:24 am, <sisyph...@optusnet.com.au> 
> <sisyph...@optusnet.com.au> wrote:
> 
> 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:
> 
> Microsoft (R) Program Maintenance Utility   Version 7.00.8882
> Copyright (C) Microsoft Corp 1988-2000. All rights reserved.
> 
>       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'
> 
> 
> 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