This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

void type

I want to know that supply void type in keil c51 REV 7.XX

following is program
#include <reg52.h>
#include <stdio.h>
#define NUMBER 2

typedef struct Test {
void (*FuncP)(void *);
void *Farg;
} Test;

int max(int a[NUMBER])
{
int z;
if (a[0]>a[1])
z=a[0];
else
z=a[1];
return(z);
}
main()
{
int a[NUMBER]={1,2};
void i;

Test *TmrTest;


TmrTest->FuncP=(void *)max;
TmrTest->Farg=(void *)&a[0];

i=(*TmrTest->FuncP)(TmrTest->Farg);
}

error infomation:
error c136: 'i': 'void' on variable
error c186: invalid dereference

or

#include <reg52.h>
#include <stdio.h>
#define NUMBER 2

typedef struct Test {
void (*FuncP)(void *);
void *Farg;
} Test;

int max(int a[NUMBER])
{
int z;
if (a[0]>a[1])
z=a[0];
else
z=a[1];
return(z);
}
main()
{
int a[NUMBER]={1,2};
int i;

Test *TmrTest;


TmrTest->FuncP=(void *)max;
TmrTest->Farg=(void *)&a[0];

i=(int *)(*TmrTest->FuncP)(TmrTest->Farg);
}
error infomation:
error c215:illegal type conversion


,follow is OK,
functin max isn't .....
#include <reg52.h>
#include <stdio.h>
#define NUMBER 2

typedef struct Test {
void (*FuncP)(void *);
void *Farg;
} Test;

int max(int a[NUMBER])
{
int z;
if (a[0]>a[1])
z=a[0];
else
z=a[1];
return(z);
}
main()
{
int a[NUMBER]={1,2};

Test *TmrTest;


TmrTest->FuncP=(void *)max;
TmrTest->Farg=(void *)&a[0];

(*TmrTest->FuncP)(TmrTest->Farg);
}