On 05/10/02 00:09 +0100, Mark Fowler wrote: > On Fri, 4 Oct 2002, Brian Ingerson wrote: > > > I don't know what's happening here. Could you put a short failing test > > on the wiki site? > > First up, I got scared by the wiki and the YAML and the YAML and the wiki.
Why? I just use YAML to structure my thoughts. You don't have to. I just think it's fun. (And machine parsable :) > Can we use RT? Sure. I'm not a big user of RT. I'll accomodate you though. Just let me know when you post a bug. (or does rt do that automatically?) > > Anyway, I narrowed down the problem to declaring a second "use Inline" > block in the same module. This code is online at > http://2shortplanks.com/temp/testcase.tar.gz > > package Foo; > use Inline 'C' => <<'END_OF_C', VERSION => 1.01, NAME => __PACKAGE__; > use Inline 'C' => <<'END_OF_C', VERSION => 1.01, NAME => __PACKAGE__; > /* as soon as a second C block is created we get all > kinds of hell breaking loose */ I'll say. You can't do this. Each invocation of Inline creates a shared object which then gets loaded. The NAME parameter tells Inline what to name the object. In your case it will be 'Foo.so'. But you are trying to create two objects with the same name. So the first one is probably getting overridden by the second. Now before, when you didn't use the NAME parameter, Inline made up a name by concatenating the package name 'Foo' with part of the MD5 hash (enough to make it unique). So maybe you ended up with Foo_8e5f.so and Foo_45d9.so. And everything worked. But you want to make this into a module. And it wouldn't be nice of me to let the world's perl installations get polluted with the likes of F00_8e5f.so. So I force you to use a NAME. (I'm protecting you in the end. Angry mongers might demand your head.) But that means you can't have two shared objects. And that makes you sad. What to do? Put everything in one! That would be easiest. Use the __C__ syntax and throw it all down below. I'd be interested in knowing why you want 2 objects. There are a few rules when making Inline modules: - One Inline block per module. - NAME must be the same as the module package. - If you really want two objects you must put them in separate modules with separate packages. Don't try to get tricky here and use a second module with the same package name. That won't work. - To bundle two or more Inline-based modules in the same CPAN distribution each one must have its own Makefile.PL. This means you must use subdirectories. Don't worry, it's easy. And it works great. Should I put this on the wiki? Cheers, Brian
