- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Problem with strpbrk
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-05-2007 10:14 AM
тАО07-05-2007 10:14 AM
I'm having difficulty with strpbrk going into a recursive loop that explodes the stack. This is happened when I use my c++ compiler and not my c compiler. The application i'm building right now has be be built in c++.
I'm on an HP11.23v2 IA machine. 32 bit compiles. aCC A.06.13. For the life of me I cannot figure out why this is happening but know the problem has to be really easy and something i'm missing.
Thanks,
Fred
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-05-2007 10:25 AM
тАО07-05-2007 10:25 AM
Re: Problem with strpbrk
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-05-2007 11:11 AM
тАО07-05-2007 11:11 AM
Re: Problem with strpbrk
Yes both strings are NULL terminated. It is single threaded and the debugger shows the strings clean going in. Both strings are const.
Thanks,
Fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-05-2007 09:06 PM
тАО07-05-2007 09:06 PM
SolutionThere are 3 or 4 C string functions that are required to be overloaded by the C++ Standard. It looks like strpbrk is one of them because of the broken C definition.
I would not expect them to fail unless you illegally had a macro like:
#define const
Or used the old cfront trick of -Dconst=.
>Clay: Note that this function expects both of the strings to be const.
That's not what "const" means. It means that the function doesn't modify them, so it allows const strings. And due to qualification conversion, a char* can be passed to a const char*.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2007 04:05 AM
тАО07-06-2007 04:05 AM
Re: Problem with strpbrk
>>Can you grep for strpbrk /opt/aCC/include_std/*?
Yes, I have been stareing at it for a day now, particularly in cstring. I ran the grep you asked, here is what it spit out:
cstring:#define strpbrk __strpbrk_keep_out
cstring:#undef strpbrk
cstring:#pragma builtin strpbrk
cstring:#pragma extern strchr, strpbrk, strrchr, strstr, memchr
cstring: extern "C" const char* strpbrk(const char *, const char *);
cstring: inline char* strpbrk(char *s, const char *p);
cstring: return const_cast
cstring:using ::strpbrk;
string.h:using std::strpbrk;
>>I would not expect them to fail unless you illegally had a macro like:
>>#define const
>>Or used the old cfront trick of -Dconst=.
I did find a #define const behind a #ifndef __STDC__ definition. I was worried that it might get picked up since i'm using the ++ compiler, so I deleted it. I rebuilt everything from scratch, same problem.
Is there any tusc or elfdump information that I could provide that would help?
Thanks,
Fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2007 06:10 AM
тАО07-06-2007 06:10 AM
Re: Problem with strpbrk
Here are some things I think may be important. The code with strpbrk and strchr is in an archive library that was compiled in ansi c. The running program was compiled in c++ and linked with this .a file. I went ahead an made an all c++ version and still no joy.
Fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2007 10:41 AM
тАО07-06-2007 10:41 AM
Re: Problem with strpbrk
You hit the nail on the head. I did remove the offending #define const and kept having the problem. Turns out that the #define const was being autogenerated. Once I got rid of that...it worked like a charm!
Thanks
Fred
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-06-2007 02:42 PM
тАО07-06-2007 02:42 PM
Re: Problem with strpbrk
So the proper test would be to use:
#if !defined(__STDC__) && !defined(__cplusplus)