[asterisk-dev] Using command line arguments in other file than asterisk.c

Julian Fleischhauer julian.fleischhauer at gmail.com
Tue Sep 13 10:09:59 CDT 2016


Hi everyone,

Sorry if this mail is a repost, but I can't figure out if my first mail
went through, because I have first been registered now.

I have an issue which I can't fix myself.

I want to use a command line argument variable in a different file than
asterisk.c. I know it can be realized using the "extern" keyword. The
command line argument handling works just fine. But at the moment a SIP
message gets into the system and the line, where the variable is used, get
executed, the system remains silent. This is the code:

*asterisk.c*

#include "asterisk/chan_sip.h"
int VAR = 0;
[parsing of command line arguments and set VAR to value]
printf("%d\n", VAR); <== correct output

*chan_sip.h*

extern int VAR;

*chan_sip.c*

#include "asterisk/chan_sip.h"
extern int VAR;
printf("%d\n", VAR); <== system prints nothing

I actually do not want to pass the variable as a function argument.

Can you spot any mistakes? Thank you in advance!

Regards,
Juliannn
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-dev/attachments/20160913/20e98c65/attachment.html>


More information about the asterisk-dev mailing list