Hi Eric,

Your code fails to compile because the function steps() is masked with the
parameter 'steps' inside the function two_step. Here is a diff -u of the
fixed code:

---8<---
--- old.pl       Tue Jan  2 15:31:41 2001
+++ new.pl       Tue Jan  2 15:32:55 2001
@@ -15,11 +15,11 @@
     printf("I can only hope to get this far\n"); 
 }
       
-void two_step(int steps)
+void two_step(int isteps)
 {
   int *dance = NULL;
 
-  dance = (int*)malloc(steps*sizeof(int));
+  dance = (int*)malloc(isteps*sizeof(int));
   if (dance=NULL)
      handle_error(1, 1);

---8<---

The output from 'perl new.pl' was: "I can only hope to get this far"

AFAIK, there isn't a default typemap for int*. You'll have to create such
a typemap if you want to bind void steps(int *) to Perl. If Inline is
trying to bind to an int* without such a typemap, then you have found a
bug. I'd be interested in seeing the whole XS file if the problem
persists.

Good luck,
Neil Watkiss
[EMAIL PROTECTED]

On Tue, 2 Jan 2001, Eric Kort wrote:

> Dear Inliners:
>
> I have come across what I think may be a bug in Brian's magnificent module,
> or (more likely) a bug in my brain.  I am using version 0.30 of Inline, and
> version 1.0 of my brain.
> 
> Sometimes when I fiddle with the parameters passed to an inline'd sub, I get
> this sort of error:
> 
> Error: invalid argument declaration 'dance_steps' in main_blah_blah.xs, line
> 39.
> 
> The offending declaration is always (so far) a pointer.  I have had
> previously working subroutines break by removing a preceding parameter
> (typically an int).
> 
> Snippet one below generates just such an error.  Snippet two contains the
> offending bit of the resulting xs file.  Note that there is no type for the
> offending parameter.  Shouldn't it say "int  *dance_steps" ?
> 
> Thanks for any clarification you can give on this,
> 
> Eric
> 
> ---------8<--snippet one-----------------------
> 
> #!/usr/bin/perl -w
> 
> use strict;
> 
> my $dance = 100;
> 
> two_step($dance);
> 
> exit;
> 
> use Inline C => <<'END_OF_C_CODE'; 
> 
> void steps(int *dance_steps)
> {
>     printf("I can only hope to get this far\n"); 
> }
>       
> void two_step(int steps)
> {
>   int *dance = NULL;
> 
>   dance = (int*)malloc(steps*sizeof(int));
>   if (dance=NULL)
>      handle_error(1, 1);
> 
>   steps(dance);
> 
>   free(dance);
> 
> }
> 
> handle_error (int err_no, int trap)
> {
>   printf("Could not allocated sufficient memory! (Error #1 at trap %d)\n\n",
> trap);
>   exit(0);
> }
> 
> END_OF_C_CODE
> 
> -------8<--snippet two---------------------------
> <snip>
> 
> PROTOTYPES: DISABLE
> 
> void
> steps (dance_steps)
>               dance_steps
> 
> <snip>
> 


Reply via email to