* POSIX, alpha, strtok() and char *'s...
@ 1998-03-27 17:33 s.c. trusty
1998-03-27 18:42 ` Uncle George
1998-03-27 19:47 ` Michal Jaegermann
0 siblings, 2 replies; 3+ messages in thread
From: s.c. trusty @ 1998-03-27 17:33 UTC (permalink / raw)
To: axp-list
greetings.
my question regards POSIX saying that strtok returns a char *.
on my axp, sizeof(char *) = 8
sizeof(strtok(configToken, \",\")) is 4 (!)
hence, sizeof((char *)strtok(configToken, ",")) = cast to pointer from
integer of different
size
what is the typical way to solve/explain this? i realize this is a
probably old and moldy, but haven't had any luck tracking down the
solution.
thanks any and all in advance,
stuart trusty,
sysadmin,
linux labs
tucson.az.us
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: POSIX, alpha, strtok() and char *'s...
1998-03-27 17:33 POSIX, alpha, strtok() and char *'s s.c. trusty
@ 1998-03-27 18:42 ` Uncle George
1998-03-27 19:47 ` Michal Jaegermann
1 sibling, 0 replies; 3+ messages in thread
From: Uncle George @ 1998-03-27 18:42 UTC (permalink / raw)
To: axp-list
i sorta expect it to be casted in one of the .h's. if its not defined, or
u dont include the .h, then the def return is an int ( as so i believe, so
i do ).
u can use gcc -E to see all the includes/cast'ings in the output of the
compile.
gat
s.c. trusty wrote:
> greetings.
>
> my question regards POSIX saying that strtok returns a char *.
>
> on my axp, sizeof(char *) = 8
>
> sizeof(strtok(configToken, \",\")) is 4 (!)
>
> hence, sizeof((char *)strtok(configToken, ",")) = cast to pointer from
> integer of different
> size
>
> what is the typical way to solve/explain this? i realize this is a
> probably old and moldy, but haven't had any luck tracking down the
> solution.
>
> thanks any and all in advance,
>
> stuart trusty,
> sysadmin,
> linux labs
> tucson.az.us
>
> --
> To unsubscribe: send e-mail to axp-list-request@redhat.com with
> 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: POSIX, alpha, strtok() and char *'s...
1998-03-27 17:33 POSIX, alpha, strtok() and char *'s s.c. trusty
1998-03-27 18:42 ` Uncle George
@ 1998-03-27 19:47 ` Michal Jaegermann
1 sibling, 0 replies; 3+ messages in thread
From: Michal Jaegermann @ 1998-03-27 19:47 UTC (permalink / raw)
To: axp-list
>
>
> my question regards POSIX saying that strtok returns a char *.
>
> on my axp, sizeof(char *) = 8
>
> sizeof(strtok(configToken, \",\")) is 4 (!)
Are you sure that you included a header file and that compiling
with -Wall does not come up with any warnings? Undeclared types
default in C to int (sizeof(int) is four on Alpha).
Your result is typical for a buggy coding which trips so many
on Alpha
> hence, sizeof((char *)strtok(configToken, ",")) = cast to pointer from
> integer of different
> size
for reasons you state so clearly. You can get away with something
like that on Intel.
I cannot check it right now but I have a strong suspicion that
your C is not correct. Or you found a true bug in headers.
Michal
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1998-03-27 19:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1998-03-27 17:33 POSIX, alpha, strtok() and char *'s s.c. trusty
1998-03-27 18:42 ` Uncle George
1998-03-27 19:47 ` Michal Jaegermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox