My question is quit simple but is is very difficult (for me) to implement it.
So, i want to read some config_data out of a perl module. In perl it looks like that.
The module:
And the programm:package MyConfig; use strict; use Exporter; use vars qw(@ISA @EXPORT $var); @ISA = qw(Exporter); @EXPORT = qw($var); $var = "SOME_FOO"; 1;
So far, so good. But now I want the same in C. I tried a little bid and thats my C code#!/usr/bin/perl -w use strict; use MyConfig; printf(">%s<\n",$MyConfig::var);
Makefile:#include <stdio.h> #include <stdlib.h> #include <EXTERN.h> #include <perl.h> static PerlInterpreter *my_perl; int main(void) { char *var; my_perl = perl_alloc(); perl_construct(my_perl); var = SvPV_nolen(get_sv("MyConfig::var", TRUE)); printf(">%s<\n", var); return(EXIT_SUCCESS); }
I get's a Segmentation fault. Hope anyone can help me out :-)PERL_CCOPTS = `perl -MExtUtils::Embed -e ccopts` PERL_LDOPTS = `perl -MExtUtils::Embed -e ldopts` all: gcc -g -o read_config.o -c read_config.c $(PERL_CCOPTS) gcc -g -o read_config read_config.o $(PERL_LDOPTS)
Thanks a lot. Regards Neal
P.S. I know, my english is not the best. So please forgive me.
In reply to Config Module for C and Perl by Neal_the_real
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |