EZK <peter.w.eddy@lmco.com> wrote:
Sounds like a possible name mangling problem. Are you calling any C
functions
from your C++ code? Are they protected from name mangling (extern “C”)?
It’s the OS calls that are giving me compiler errors. If I just add a
extern “C” int rsrcdbmgr(…), I get redeclairation errors. How do I
compile library calls without modifying the header files myself?
I took the sample from the help system, and made some modifications to
get it to compile and link for C++.
Note the use of extern “C” around the includes, so you don’t need to modify
headers yourself. If the file is names test.cc, you can compile it
using “QCC ./test.cc -o test” and it should build fine.
-Adam
amallory@qnx.com
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern “C” {
#include <sys/rsrcdbmgr.h>
#include <sys/rsrcdbmsg.h>
}
#endif
int main(int argc, char **argv) {
int count;
rsrc_request_t req;
memset(&req, 0, sizeof(req));
req.length = 1;
req.flags = RSRCDBMGR_DMA_CHANNEL;
count = 1;
if (rsrcdbmgr_attach( &req, count) == -1) {
perror("Problem attaching to resource ");
exit(1);
}
printf(“You can use DMA channel 0x%llx \n”,
req.start);
/* Do something with the acquired resource */
/* To return the resource to the database: */
if (rsrcdbmgr_detach( &req, count) == -1) {
perror(“Problem detaching resource \n”);
exit(1);
}
return(0);
}