Hi All,
I am trying to compile some simple programs on mini2440 with linux
burned on it
program1: Test.c
------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void sub (float, float);
void add (float, float);
void (*p[2])(float, float) = {sub,add};
int main ()
{
float a;
float b;
a = 30;
b = 10;
p[0](a,b);
p[1](a,b);
}
void sub (float a,float b)
{
printf ("I am in sub\n");
b = a-b;
printf ("substraction is %f\n",b);
}
void add (float a,float b)
{
printf ("I am in add\n");
b = a+b;
printf ("I am in add %f\n",b);
}
------------------------------------------------------------------------
I compiled abive programs as
#arm-none-linux-gnueabi-gcc -mfloat-abi=soft Test.c -o Test
Above program does not work. While running it gives error of illegal
operation.
but program below works fine.
program2:Test.c
------------------------------------------------------------------------
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void sub (float, float);
void add (float, float);
int main ()
{
float a;
float b;
a = 30;
b = 10;
add(a,b);
sub(a,b);
}
void sub (float a,float b)
{
printf ("I am in sub\n");
b = a-b;
printf ("substraction is %f\n",b);
}
void add (float a,float b)
{
printf ("I am in add\n");
b = a+b;
printf ("I am in add %f\n",b);
}
------------------------------------------------------------------------
-
I compiled both of them with same options. Only difference is that one
uses
function pointers in place of direct function call. But I receive
illegal
operation in first program which used function pointers.
Anyone has any idea why such thing is happening. I think there is some
option which I need to use while compilation. Please help.
Thanks
-R/\\/I-