c and shared libs ?? how to do it right?

Reply

Join Date: Feb 2006
Posts: 9
Reputation: crusty_collins is an unknown quantity at this point 
Solved Threads: 0
crusty_collins crusty_collins is offline Offline
Newbie Poster

c and shared libs ?? how to do it right?

 
0
  #1
Feb 14th, 2006
Hey, I am a newbie to all of this so please don't flame me for a stupid question.
I am trying to write a shared lib that will initialize a connection to a messaging deamon. Then the library will be called at intervals and send data.

My problem is that I am having issues with passing a datatype to a lib. I would think that the following would work.
<code>
void
initRv( tibrvTransport *transport)
{
char* serviceStr = "7500";
char* networkStr = "";
char* daemonStr = "tcp:7500";

status = tibrvTransport_Create(*transport, serviceStr, networkStr, daemonStr);
return;
}
<\code>

Give me a warning: passing arg 1 of `tibrvTransport_Create' makes pointer from integer without a cast

I think I have the pointers screwed up.??
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 178
Reputation: jim mcnamara is on a distinguished road 
Solved Threads: 10
jim mcnamara jim mcnamara is offline Offline
Junior Poster

Re: c and shared libs ?? how to do it right?

 
0
  #2
Feb 14th, 2006
try
  1. status = tibrvTransport_Create(transport, serviceStr, networkStr, daemonStr);
transport is already a pointer, so using *transport says to pass that value of the object pointed to, not the address. Pointers are addresses.

It also seems you are not prototyping functions. Or maybe not including header files.

There should be separate prototypes for each of the functions so that compiler won't issue a warning, instead it will issue a fatal error if the datatype of an argument is wrong.

  1. I made up this prototype:
  2. void tibrvTransport_Create(tibrvTransport *, char *, char *, char *);

It's possible *transport was actually correct, but the compiler does not seem to know.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 9
Reputation: crusty_collins is an unknown quantity at this point 
Solved Threads: 0
crusty_collins crusty_collins is offline Offline
Newbie Poster

Re: c and shared libs ?? how to do it right?

 
0
  #3
Feb 14th, 2006
Wonderful, you confirmed what I was working on. Thanks for the help. It works!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC