HPE GreenLake Administration
- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: improper behaviour with -O option
Operating System - HP-UX
1832145
Members
2869
Online
110038
Solutions
Forums
Categories
Company
Local Language
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
back
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
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- 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
06-02-2003 03:10 AM
06-02-2003 03:10 AM
improper behaviour with -O option
Hi,
I have a c code something like this
void RegisterFunc(
int (*cb)(char *)
void *client_data
)
{
callBackList[i].cb = cb;
callBackList[i].cdata = client_data;
}
void InvokeCallback()
{
callBackList[i].cb((char *)callBackList[i].cdata)
}
int my_func(char *name)
{
if(strcmp(name, "TEST"))
return -1;
/* do the processing */
}
void foo()
{
RegisterFunc(my_func, "TEST");
}
The argument name coming to 'my_func' is NULL when I use -O option for cc. It works fine when I remove the optimisation option.
Please suggest a way out
TIA
satya
I have a c code something like this
void RegisterFunc(
int (*cb)(char *)
void *client_data
)
{
callBackList[i].cb = cb;
callBackList[i].cdata = client_data;
}
void InvokeCallback()
{
callBackList[i].cb((char *)callBackList[i].cdata)
}
int my_func(char *name)
{
if(strcmp(name, "TEST"))
return -1;
/* do the processing */
}
void foo()
{
RegisterFunc(my_func, "TEST");
}
The argument name coming to 'my_func' is NULL when I use -O option for cc. It works fine when I remove the optimisation option.
Please suggest a way out
TIA
satya
1 REPLY 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2003 07:42 AM
06-02-2003 07:42 AM
Re: improper behaviour with -O option
If "callBackList[i].cb" is some generic function pointer type, then you should cast it before calling through it.
*((int (*)(char *)) callBackList[i].cb)((char *)callBackList[i].cdata)
That will tell the compiler what the parameter list should look like. Without that it may assume that the parameter to the call is a (32-bit) integer. That would damage a 64-bit char *.
If that isn't the problem then I would suggest creating a small test case. If it fails you will have an example. If it works then you will have a difference to ponder while looking at your original code.
*((int (*)(char *)) callBackList[i].cb)((char *)callBackList[i].cdata)
That will tell the compiler what the parameter list should look like. Without that it may assume that the parameter to the call is a (32-bit) integer. That would damage a 64-bit char *.
If that isn't the problem then I would suggest creating a small test case. If it fails you will have an example. If it works then you will have a difference to ponder while looking at your original code.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Events and news
Customer resources
© Copyright 2025 Hewlett Packard Enterprise Development LP