Function pointers not working

Ravi
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-

davef
I have used function pointers on a 8bit AVR device using WinAvr (GCC) and
don't recall anything you could switch on or off in the compiler for
function pointers.

Good luck in your search.

Trevor Blackwell
I can reproduce. It's trying to use the BLX instruction for function
pointer calls, which isn't
supported on the S2C2440. 

Adding -march=armv4t to the gcc command line will make it work. I don't
know if that's the right long-term solution.