Module scope conflicts
Archives Forums/BlitzMax Bug Reports/Module scope conflicts
| ||
To reproduce the first bug, create a module called foo.math with the following source:Strict Module Foo.Math Import BRL.Math Function Add(num1,num2) Return num1+num2 End Function When building, it will error out with the following: C:/BlitzMax/mod/foo.mod/math.mod/.bmx/math.bmx.debug.win32.x86.s [10]: ___bb_math_math: error: symbol already defined. For the second bug, use the following source: foo.mod/math.mod/math.bmx Strict Module Foo.Math Function Add(num1,num2) Return num1+num2 End Function foo2.mod/math.mod/math.bmx Strict Module Foo2.Math Function Subtract(num1,num2) Return num1+num2 End Function test.bmx Strict Import Foo.Math Import Foo2.Math Add(2,1) Subtract(2,1) These modules will actually build. After compiling test.bmx, you should get the following error: C:/BlitzMax/mod/foo.mod/math.mod/math.debug.win32.x86.a(math.bmx.debug.win32.x86.o): multiple definition of `__bb_math_math' C:/BlitzMax/mod/foo2.mod/math.mod/math.debug.win32.x86.a(math.bmx.debug.win32.x86.o): first defined here Build Error: Failed to link C:/Documents and Settings/Owner/Desktop/test.debug.exe I've tested both under 1.41 on Windows and Linux but I have noticed the behavior in previous versions. |
| ||
This is due to the way modules are initialized. An entrypoint is created for each module, and it uses the format "__bb_<modname>_<modname>". It could be that the intended form was "__bb_<scope>_<modname>", and it may have been overlooked in development. |
| ||
That's what I was thinking. Normally, I would have figured out a fix but unfortunately that's not possible... |
| ||
If the entrypoint is indeed badly configured perhaps this should be changed for the next BlitzMax release. I suppose this will conflict with pre-compiled 3rd party modules but it's worth the pain as it'll give a lot more flexibility. |
| ||
If the entrypoint is indeed badly configured perhaps this should be changed for the next BlitzMax release Hah... this is a "feature" of BlitzMax. This is how it is. One needs to live with it, and work around it. |
| ||
I knew of the current limitation. But if it can be resolved then why not? Can it be changed. And how is this actually a feature? |
| ||
It's a feature insofar as Mark said it would never be changed. (there's probably even a post circa 2007 which embellishes on the subject a bit more) |
| ||
I'd like to resurrect this report as I've encountered yet another issue that can by no means be intentional. I've noticed that if you have two modules of different scopes (but the same name) and import both into your source, only the code in latter module (and subsequently all modules it imports) gets executed. As an example, using my rendering engine, https://github.com/kfprimm/maxb3d Swap the two imports and you'll see that CreateWindow fails in one order, and CreateCamera fails in the other. |