- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Re: extern C linkage on aCC6
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
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-01-2008 05:31 AM
тАО07-01-2008 05:31 AM
extern c linkage in hpitan
I am facing a problem where I have a file main.cpp in which I have a function int abc(RequestInfo* request,BaseCommon *(*GetRequest)(RequestInfo *) /*= 0*/) {
. //My code
.
.
.
.
}
There is a header file xyz.h which includes
extern "C" {
extern int abc(RequestInfo *requestInfo, BaseCommon *(*GetRequest)(RequestInfo *) = 0);
/**
* Routines
*/
}
This xyz.h is included in main.cpp.
When I create a shared library and try to load my module I get a runtime error which gives me an error
/usr/lib/hpux64/dld.so: Unsatisfied code symbol 'abc' in load module
But when I remove the "extern C" linkage the things work fine.
Please let me what am I missing or is this the expected behaviour.
I am using hpitan 64-bit machine with aCC compiler
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2008 05:35 AM
тАО07-01-2008 05:35 AM
Re: extern c linkage in hpitan
I would suppose that "hpitan" stands for "HP Itanium", though that's a new abbreviation on me.
Consider the poor search engines...
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2008 10:52 AM
тАО07-01-2008 10:52 AM
Re: extern c linkage in hpitan
of supplying a complete failing test case?
> [...] I have a file main.cpp in which I
> have a function int abc([...]
So, abc() is in a C++ source file? And it
itself is not bracketed by an '"extern C"',
but its prototype is? I'm not C++-fluent,
but I don't think that I'm amazed by your
problem.
> But when I remove the "extern C" linkage
> the things work fine.
Or, I'd guess, if you add another one around
abc(). Telling the C++ compiler that you
have a C function named abc() when you
actually have a C++ function named abc()
sounds to me as if it might confuse someone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-01-2008 02:14 PM - edited тАО09-11-2011 06:55 AM
тАО07-01-2008 02:14 PM - edited тАО09-11-2011 06:55 AM
Re: extern C linkage on aCC6
>int abc(RequestInfo*,BaseCommon* (*)(RequestInfo*))
As mentioned by Steven, this isn't a good way to program. You should always be explicit with extern "C", inline, public and virtual keywords.
Your particular case is documented in the porting to aCC6 guide and has your picture on it: :-)
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=2708d7c682f02110d7c682f02110275d6e10RCRD
ABI-9. Mangling extern "C" names with parms of type pointer to function
>JRF: I would suppose that "hpitan" stands for "HP Itanium"
The correct term is Integrity or IPF. But the real topic should be aCC6.
>Steven: if you add another one around abc(). Telling the C++ compiler that you have a C function named abc() when you actually have a C++ function named abc() sounds to me as if it might confuse someone.
The Standard allow the first linkage spec to be inherited by the second. But there is an "if" about matching. Having pointers to C vs C++ functions causes the match to fail, unless they use a typedef in an extern "C" block.