Re: Inline::C Cookbook addition
[email protected] (Ron Grunwald via inline) Fri, 9 Dec 2016 06:27:00 +0800
| Newsgroups | perl.inline |
|---|---|
| Message-ID | <[email protected]> |
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, [email protected] wrote: >=20 > The "use Inline C =3D> Config =3D> ..." line can be removed if you = rewrite the __C__ section as: >=20 > __DATA__ > __C__ > #define N_MP 4 >=20 > void CalcSurfaceHeights() { > double x[N_MP], y[N_MP], z; > int ix; > char *mesh_data =3D SvPV_nolen(get_sv("main::mesh_data", 0)); >=20 > 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); >=20 > for (ix=3D0; ix < N_MP; ix++) { > z =3D 0.5*( sin(x[ix]) + sin(y[ix]) ); >=20 > printf("Surface-Height: %6.3f Mesh-Point: %6.2f, %6.2f\n", > z, x[ix], y[ix]); > } > } >=20 > 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. >=20 > 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. >=20 > Cheers, > Rob >=20