Njk00
08-02-2010, 13:01
Salve
non capisco bene come si dichiari la funzione clone: io ho fatto così
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sched.h>
int test(int);
int main(int argc, char** argv)
{
int* param = malloc(sizeof(int));
*param = 5;
int* stack = malloc(sizeof(int));
int c = 2;
/*int clone(int (*fn)(void *), void *child_stack,
int flags, void *arg, ...*/
int result = clone(test(c), stack + sizeof(int), CLONE_PARENT, c);
return 0;
}
int test(int a)
{
printf("In test function a = %d\n", a);
a = 19;
printf("a = %d\n", a);
return a;
}
Tuttavia mi da i seguenti warnings:
1.c: In function main:
1.c:21: warning: passing argument 1 of clone makes pointer from integer without a cast
1.c:21: warning: passing argument 4 of clone makes pointer from integer without a cast
Perché?
Grazie a tutti
non capisco bene come si dichiari la funzione clone: io ho fatto così
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sched.h>
int test(int);
int main(int argc, char** argv)
{
int* param = malloc(sizeof(int));
*param = 5;
int* stack = malloc(sizeof(int));
int c = 2;
/*int clone(int (*fn)(void *), void *child_stack,
int flags, void *arg, ...*/
int result = clone(test(c), stack + sizeof(int), CLONE_PARENT, c);
return 0;
}
int test(int a)
{
printf("In test function a = %d\n", a);
a = 19;
printf("a = %d\n", a);
return a;
}
Tuttavia mi da i seguenti warnings:
1.c: In function main:
1.c:21: warning: passing argument 1 of clone makes pointer from integer without a cast
1.c:21: warning: passing argument 4 of clone makes pointer from integer without a cast
Perché?
Grazie a tutti