develooper Front page | perl.perl5.porters | Postings from December 2016

[perl #130393] h2xs: Support for _Bool/stdbool.h?

Thread Next
From:
Stefan Tauner
Date:
December 23, 2016 23:43
Subject:
[perl #130393] h2xs: Support for _Bool/stdbool.h?
Message ID:
rt-4.0.24-11231-1482505827-369.130393-75-0@perl.org
# New Ticket Created by  Stefan Tauner 
# Please include the string:  [perl #130393]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=130393 >


Hi,

I have used h2xs for the first time today to start the creation of a
Perl package based on a small C library. make failed to build it
apparently due to the usage of a bool type for a parameter in one of
the library's exported functions resulting in

error: ‘arg1’ undeclared (first use in this function)
  RETVAL = dap_poll(context, arg1);

The generated code in the .xs is:

XS_EUPXS(XS_function_name)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "context, arg1");
    {
	struct some_context *	context;
	int	RETVAL;
	dXSTARG;
[...]

Note that there is no variable definition for "arg1" (whose name is
actually made up by h2xs apparently - in the library it is called wait).

When I change the library to use int instead of bool (or _Bool) then
the parameter is handled correctly (NB: "wait" in the croak_xs_usage()
call):

XS_EUPXS(XS_function_name)
{
    dVAR; dXSARGS;
    if (items != 2)
       croak_xs_usage(cv,  "context, wait");
    {
	struct some_context *	context;
	int	wait = (int)SvIV(ST(1))
;
	int	RETVAL;
	dXSTARG;
[...]

_Bool is a C type introduced in C99, bool is a typedef declared by
stdbool.h also from C99 and nothing fancy at all. I am using h2xs from
ubuntu's Perl 5.22.1 but I could not find any hint on bool support in
h2xs in Perl git thus I am reporting this here.

KR
-- 
Dipl.-Ing. Stefan Tauner
Research and Development
Embedded Systems Department

University of Applied Sciences Technikum Wien
Hoechstaedtplatz 6, 1200 Vienna, Austria
T: +43 1 333 40 77-316
E: stefan.tauner@technikum-wien.at
I: embsys.technikum-wien.at
I: www.technikum-wien.at


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About