06-02-2003
1,
0
Join Date: Jun 2003
Last Activity: 3 June 2003, 2:30 AM EDT
Posts: 1
Thanks Given: 0
Thanked 0 Times in 0 Posts
how to use _PROTOTYPE?
os:sco operserver 5.05
my program:
/*ptest.c*/
#include <stdio.h>
#include <stdlib.h>
static int Test0(char *buff)
{
printf("Func:Test0 %s\n",buff);
return 1;
}
static int Test1(char *buff)
{
printf("Func:Test1 %s\n",buff);
return 1;
}
_PROTOTYPE(static int Test0, (char *buff));
_PROTOTYPE(static int Test1, (char *buff));
struct commands
{
char *name;
_PROTOTYPE(void (*func),(char *buff));
};
struct commands commands[] = {
"Test0",Test0,
"Test1",Test1
};
int main()
{
struct commands *cmd;
int status;
for(cmd = commands;*(cmd->name)!='\0';cmd++)
{
printf("command:%s\n",cmd->name);
status = (*cmd->func)("this is a test!\n")
}
return 1;
}
#gcc -o ptest ptest.c
ptest.c:16: storage class specified for parameter `Test0'
ptest.c:16: parse error before `('
ptest.c:17: storage class specified for parameter `Test1'
ptest.c:17: parse error before `('
ptest.c:22: parse error before `_PROTOTYPE'
ptest.c:22: warning: no semicolon at end of struct or union
ptest.c:25: elements of array `commands' have incomplete type
ptest.c:26: warning: excess elements in struct initializer
ptest.c:26: warning: (near initialization for `commands[0]')
ptest.c:26: warning: excess elements in struct initializer
ptest.c:26: warning: (near initialization for `commands[1]')
ptest.c:27: warning: excess elements in struct initializer
ptest.c:27: warning: (near initialization for `commands[2]')
ptest.c:28: warning: excess elements in struct initializer
ptest.c:28: warning: (near initialization for `commands[3]')
ptest.c: In function `main':
ptest.c:35: dereferencing pointer to incomplete type
ptest.c:35: increment of pointer to unknown structure
ptest.c:35: arithmetic on pointer to an incomplete type
ptest.c:37: dereferencing pointer to incomplete type
ptest.c:38: dereferencing pointer to incomplete type
ptest.c:39: parse error before `}'
why?
thanks!!!