ingydotnet / inline-c-pm

10 stars 19 forks source link

Comments in function signature cause "Undefined subroutine" but no compilation error #101

Open hadjiprocopis opened 2 years ago

hadjiprocopis commented 2 years ago

Comments in the function signature "confuse" Inline::C although there are no C-related compilation errors. In the below example, myfunc3() succeeds while the other two fail to be called with the error: "Undefined subroutine &main::myfunc called"

use Inline C => 'DATA';

# these 2 fail:
print myfunc1(42), "\n";
print myfunc2(42), "\n";

# this succeeds:
print myfunc3(42), "\n";

__END__
__C__
use Inline C => 'DATA';

# these 2 fail:
# but if you comment them out, it succeeds, there
# are no C-related compilation problems
#print myfunc1(42), "\n";
#print myfunc2(42), "\n";

# this succeeds:
print myfunc3(42), "\n";

__END__
__C__
#include <stdio.h>

int myfunc3(
    /*int a*/
    int b
);
/* comments in the function signature cause
     Undefined subroutine &main::myfunc called
*/
int myfunc1(
    /* int a */
    int b
){ fprintf(stdout, "hello %d\n", b); return 0; }

int myfunc2(
    // int a
    int b
){ fprintf(stdout, "hello %d\n", b); return 0; }

/* this is OK, even if its declaration contains comments */
int myfunc3(
  /* ahahahah */
  int b
);
int myfunc3(
    int b
){ fprintf(stdout, "hello %d\n", b); return 0; }