Quote:
Originally Posted by nocturna_gr
Thanks everybody. I must use the specific method declaration.
introuble: this works OK.
|
do you realize that
Code:
if ((d->d_type==DT_DIR) && (is_number(dir_name)==1))
return (int *)IS_PROC_ID;
else
return (int *)NOT_PROC_ID;
is returning a ptr from the function that is either going to be null, or is going to point to address 1 and segfault?
as cupubboy said, the #define'd name is getting replaced with the value. so
return (int *)IS_PROC_ID;
is the same as saying
return (int *)1;
which does not segfault there, or give warnings.. but try to print the value of the returned pointer.
printf("%d", *(selector(...)));
segfault because you are trying to access memory at address 1. cant do it. and if you are going to use the actual value of the ptr (which would work here) why not just use an int value and have the code be readable.