kripken/emscripten — Issue #151: Small, old C issue
Author: redsh
Created: 2011-12-22 22:19:52+00:00
State: open

Hello,

I am trying to compile an old library which uses this C syntax for arguments:

int foo(i) //not working
int i;
{
return i+1;
}

I noticed that emscripten compiles the function correctly, but it calls it passing an allocated pointer:

function _foo($i) {
;
var __label__;

var $1;
$1=$i;
var $2=$1;
var $3=((($2)+1)|0);
;
return $3;
}

//when calling
var $2=_foo(allocate([1234,0,0,0], ["i32",0,0,0], ALLOC_STACK));
//instead of _foo(1234);

I attach a piece of code which reproduces the issue. Any ideas on how can I fix this?

Thank you,
Francesco

#include

int foo(i) //not working
int i;
{
return i+1;
}
int bar(int i)
{
return i+1;
}
int main(void)
{
printf("%d\n",foo(1234)); //gives address of HEAP32
printf("%d\n",bar(1234)); //giver correct result
}