| | |
strtok_r() error on solaris 8
![]() |
Hi I am getting an error with some code, it compiles fine on linux but it is throwing an error on solaris, it is to do with strtok_r, the following is the error message:
sku_cache.cpp:150: implicit declaration of function `int strtok_r(...)'
sku_cache.cpp:150: assignment to `char *' from `int' lacks a cast
The code in question is:
As I said this compiles without error on linux but using solaris 8 it complains, on checking the man pages on both machines:
Solaris:
char *
strtok_r(char *str, const char *sep, char **last);
Linux:
char *strtok_r(char *s, const char *delim, char **ptrptr);
Any help would be greatly appreciated.
Thanks
Ben
sku_cache.cpp:150: implicit declaration of function `int strtok_r(...)'
sku_cache.cpp:150: assignment to `char *' from `int' lacks a cast
The code in question is:
C Syntax (Toggle Plain Text)
char *svptr; char *s; char cont[input.length()]; const char *delim = " "; const char *sdelim = "0123456789"; sprintf(cont, "%s", input.c_str()); s = strtok_r(cont, delim, &svptr);
As I said this compiles without error on linux but using solaris 8 it complains, on checking the man pages on both machines:
Solaris:
char *
strtok_r(char *str, const char *sep, char **last);
Linux:
char *strtok_r(char *s, const char *delim, char **ptrptr);
Any help would be greatly appreciated.
Thanks
Ben
Application development, webhosting, and much more: www.webcentric-hosting.com
•
•
Join Date: Mar 2004
Posts: 77
Reputation:
Solved Threads: 2
the compiler is telling u waht is wrong. the manual page apparently has an incorrect prototype, b/c gcc is telling u that it is returning an integer. try loooking at the header file and seeing if it has any notes on the function, or u can always try casting the return to a (char *) - but i dont think it is returning what u think it is.
Hi infamous,
Well on looking on /usr/include/string.h I find:
extern char *strtok_r(char *, const char *, char **);
When I attempt to change:
char *s;
to
int s;
I get rid of that error and get the following error:
implicit declaration of function `int strtok_r(...)'
Great isn't it, it says it wants an int even although there is no way I can see how the function would work with an int, when it an int it causes an error still.
Any further advice graciously recieved.
Thanks
Ben
Well on looking on /usr/include/string.h I find:
extern char *strtok_r(char *, const char *, char **);
When I attempt to change:
char *s;
to
int s;
I get rid of that error and get the following error:
implicit declaration of function `int strtok_r(...)'
Great isn't it, it says it wants an int even although there is no way I can see how the function would work with an int, when it an int it causes an error still.
Any further advice graciously recieved.
Thanks
Ben
Application development, webhosting, and much more: www.webcentric-hosting.com
Okay I have solved the problem, one of the other files in this program is using pthreads. which means I am linking with -lpthread, which includes its own thread safe version of strtok_r(), which does return an int value, however, by passing -D_REENTRANT to the compiler it uses the strtok_r in string.h instead of the one from the pthread library.
It is supposed to be a known problem in solaris (but if it is well know it is very well hidden).
Thanks for the help all the same.
Ben
It is supposed to be a known problem in solaris (but if it is well know it is very well hidden).
Thanks for the help all the same.
Ben
Application development, webhosting, and much more: www.webcentric-hosting.com
![]() |
Similar Threads
- Solaris Error Please Help! (Java)
- Connect to solaris from cygwin through pexpec, getting error "read_nonblocking()." (Python)
- Error in script (Shell Scripting)
- Signal Handler for arithmetical error (overflow, underflow, div by zero) (C)
- What is the use of #define _REENTRANT in my code? (C++)
- Error trying to run java application (Java)
Other Threads in the C Forum
- Previous Thread: Really quick G2++ question!
- Next Thread: XP style in DOS !
| Thread Tools | Search this Thread |
#include adobe api array arrays asterisks binarysearch calculate char cm copyanyfile copyimagefile copypdffile cprogramme creafecopyofanytypeoffileinc createcopyoffile createprocess() csyntax database directory dynamic feet fflush fgets file fork forloop frequency getlasterror givemetehcodez global graphics gtkgcurlcompiling hacking highest homework i/o inches include incrementoperators input interest kernel kilometer km linked linkedlist linux linuxsegmentationfault list locate logical_drives loopinsideloop. match matrix meter microsoft mqqueue mysql number odf open openwebfoundation owf pattern pdf performance pointer posix probleminc process program programming pyramidusingturboccodes radix read recursion recv repetition research scanf scheduling segmentationfault send sequential shape socket socketprograming socketprogramming stack standard string systemcall turboc unix user voidmain() wab win32api windows.h





