Re: Inline::C Cookbook addition
[email protected] (Ron Grunwald via inline) Wed, 21 Dec 2016 06:33:01 +0800
| Newsgroups | perl.inline |
|---|---|
| Message-ID | <[email protected]> |
--Apple-Mail=_38101399-5CBA-49B6-84F2-EA4C1F4C52DA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=iso-8859-1 Hi all, > 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. For completeness, I did write up the recipe and submitted it as an issue = on github about 3 days ago, https://github.com/ingydotnet/inline-c-pm/issues/56 = <https://github.com/ingydotnet/inline-c-pm/issues/56> There havn't been any comments made so far, so I'm not sure if its being = considered for the C Cookbook. Also, it looks like no updates were made to Inline::C for the last two = years. Cheers, Ron. > On 8 Dec 2016, at 3:08 pm, [email protected] wrote: >=20 >=20 > From: Ron Grunwald via inline > Sent: Thursday, December 08, 2016 1:44 AM > To: [email protected] > Subject: Inline::C Cookbook addition > Hello all, >=20 >> The code example: >>=20 >> use strict; >> use warnings; >> use Inline C =3D> Config =3D> ccflagsex =3D> "-std=3Dc99"; >> use Inline C =3D> "DATA"; >>=20 >> our $mesh_data =3D "MESH-POINTS 0.0 0.0 0.5 0.25 1.0 0.5 1.5 0.75"; >> CalcSurfaceHeights(); >>=20 >> __DATA__ >> __C__ >> #define N_MP 4 >>=20 >> void CalcSurfaceHeights() { >> double x[N_MP], y[N_MP], z; >> 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 (int 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 > 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 --Apple-Mail=_38101399-5CBA-49B6-84F2-EA4C1F4C52DA Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=iso-8859-1 <html><head><meta http-equiv=3D"Content-Type" content=3D"text/html = charset=3Diso-8859-1"></head><body style=3D"word-wrap: break-word; = -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" = class=3D"">Hi all,<div class=3D""><br class=3D""><div = class=3D""><blockquote type=3D"cite" class=3D"">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.<br class=3D""></blockquote></div><div class=3D""><br = class=3D""></div><div class=3D"">For completeness, I did write up the = recipe and submitted it as an issue on github about 3 days = ago,</div><div class=3D""><br class=3D""></div><div class=3D""><a = href=3D"https://github.com/ingydotnet/inline-c-pm/issues/56" = class=3D"">https://github.com/ingydotnet/inline-c-pm/issues/56</a></div><d= iv class=3D""><br class=3D""></div><div class=3D"">There havn't been any = comments made so far, so I'm not sure if its being considered for the C = Cookbook.</div><div class=3D"">Also, it looks like no updates were made = to Inline::C for the last two years.</div><div class=3D""><br = class=3D""></div><div class=3D"">Cheers,</div><div class=3D"">Ron.<br = class=3D""> <br class=3D""><div><blockquote type=3D"cite" class=3D""><div = class=3D"">On 8 Dec 2016, at 3:08 pm, <a = href=3D"mailto:[email protected]" = class=3D"">[email protected]</a> wrote:</div><br = class=3D"Apple-interchange-newline"><div class=3D""><br class=3D"">From: = Ron Grunwald via inline<br class=3D"">Sent: Thursday, December 08, 2016 = 1:44 AM<br class=3D"">To: <a href=3D"mailto:[email protected]" = class=3D"">[email protected]</a><br class=3D"">Subject: Inline::C Cookbook = addition<br class=3D"">Hello all,<br class=3D""><br class=3D""><blockquote= type=3D"cite" class=3D"">The code example:<br class=3D""><br = class=3D"">use strict;<br class=3D"">use warnings;<br class=3D"">use = Inline C =3D> Config =3D> ccflagsex =3D> "-std=3Dc99";<br = class=3D"">use Inline C =3D> "DATA";<br class=3D""><br class=3D"">our = $mesh_data =3D "MESH-POINTS 0.0 0.0 0.5 0.25 1.0 0.5 1.5 0.75";<br = class=3D"">CalcSurfaceHeights();<br class=3D""><br class=3D"">__DATA__<br = class=3D"">__C__<br class=3D"">#define N_MP 4<br class=3D""><br = class=3D"">void CalcSurfaceHeights() {<br class=3D""> double = x[N_MP], y[N_MP], z;<br class=3D""> char = *mesh_data =3D SvPV_nolen(get_sv("main::mesh_data", 0));<br = class=3D""><br class=3D""> sscanf(mesh_data, "MESH-POINTS = %lf%lf%lf%lf%lf%lf%lf%lf",<br class=3D""> = &n= bsp; x, y, x+1, y+1, x+2, y+2, = x+3, y+3);<br class=3D""><br class=3D""> for (int ix=3D0; ix = < N_MP; ix++) {<br class=3D""> z =3D = 0.5*( sin(x[ix]) + sin(y[ix]) );<br class=3D""><br class=3D""> = printf("Surface-Height: %6.3f Mesh-Point: = %6.2f, %6.2f\n",<br class=3D""> = z, x[ix], = y[ix]);<br class=3D""> }<br class=3D"">}<br = class=3D""></blockquote><br class=3D"">The "use Inline C =3D> Config = =3D> ..." line can be removed if you rewrite the __C__ section as:<br = class=3D""><br class=3D"">__DATA__<br class=3D"">__C__<br = class=3D"">#define N_MP 4<br class=3D""><br class=3D"">void = CalcSurfaceHeights() {<br class=3D""> double x[N_MP], y[N_MP], = z;<br class=3D""> int ix;<br class=3D""> char = *mesh_data =3D SvPV_nolen(get_sv("main::mesh_data", 0));<br = class=3D""><br class=3D""> sscanf(mesh_data, "MESH-POINTS = %lf%lf%lf%lf%lf%lf%lf%lf",<br class=3D""> = &n= bsp; x, y, x+1, y+1, x+2, y+2, x+3, = y+3);<br class=3D""><br class=3D""> for (ix=3D0; ix < N_MP; = ix++) {<br class=3D""> z =3D 0.5*( sin(x[ix]) + = sin(y[ix]) );<br class=3D""><br class=3D""> = printf("Surface-Height: %6.3f Mesh-Point: %6.2f, = %6.2f\n",<br class=3D""> = z, = x[ix], y[ix]);<br class=3D""> }<br class=3D"">}<br class=3D""><br = class=3D"">All I've done is move the declaration of "ix" from the for() = loop to the declaration section at the beginning of = CalcSurfaceHeights().<br class=3D"">This then enables the code to = compile using compilers (such as Microsoft compilers) that are not = C99-compliant.<br class=3D""><br class=3D"">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.<br class=3D""><br class=3D"">Cheers,<br class=3D"">Rob<br = class=3D""><br class=3D""></div></blockquote></div><br = class=3D""></div></div></body></html>= --Apple-Mail=_38101399-5CBA-49B6-84F2-EA4C1F4C52DA--