PDA

View Full Version : Character Arguments in Ext Module


Don Johnson
11-07-2003, 10:43 PM
In Lahey .NET FORTRAN,
I'm having a problem where I get a linking error when I try to use character arguments in an external module. However, if I use the same routines in the same module, it works fine.
I have one module making calls in another module, both are in .NET.
The error I get is
FRT:2512 Argument of demosub for which the OPTIONAL attribute is not specified must not be omitted.

The external call works with any number of non-character arguments, and also if I place the subroutine in ForLib with the character arguments. Any ideas on why it breaks externally?
Or how to fix it?


ForLib.TopSub calls DemoMod.demosub....code:

module DemoMod
contains
subroutine demosub(intval, charval)
use System
integer*4, intent(in) :: intval
character*(*), reference, intent(in) :: charval
...
end subroutine
end module DemoMod



module ForLib
contains
subroutine TopSub(xxx)
use DemoMod
integer*4 xxx
character*64 charxxx
...

call demosub(xxx,charxxx)
end subroutine
end module ForLib

tzeis
11-10-2003, 05:33 PM
Hmmm. When I compile the code, I don't see the error. It could be that there is something in the "..." that is causing the problem, or you could be exersizing an old bug, if you don't have the latest compiler patch. If you compile the code as it is posted (comment out the "..." lines) do you see the same error?

Don Johnson
11-10-2003, 09:50 PM
Actually, DemoMod is compiled into a separate DLL.

I tried it all in the same file at compile time, and it worked then too. I'm wondering if I just need some sort of different compiling or linking flag. I need DemoMod to be seperate, as it will be a lib that will be used in many modules.

Suggestions? Can you get it to work if you have DemoMod as it's own DLL?

Thanks!

tzeis
11-10-2003, 10:17 PM
You need to add a reference to tell the compiler to look at the other dll for definitions.

Assuming that you compile file1 into a dll using the class library project, in the calling Visual studio project, add a reference to the first class library project.
Do this by right clicking on the "References" folder in the calling project.

If you do command line, use the -refer option to add the reference. The -refer option is kind of the .NET equivalent of the Win32 -mod option.

Does this help?

Don Johnson
11-10-2003, 10:44 PM
I have done both.
It sees the method just fine, but has some problem with the arguments when I use characters. With just an integer, it works fine.

I notice using ildasm that it treats characters as unsigned integers in the DemoMod DLL, and adds a polymorphed demosub with an extra argument
demosub: void(int32&,unsigned int8[])
demosub: void(int32&,unsigned int8[], class [Fujitsu.Fortran]Fujitsu.Fortran.FortranVariableDescriptor)

It's like it only sees the latter of the two, and expects the extra argument. Can you try making DemoMod into a class library, and reference it.

Thanks!

tzeis
11-10-2003, 11:30 PM
Yes, I can see the error if I compile the files separately. This looks like a bug. Probably your best workaround is to put both source files into the same project so that they are compiled into the same dll. The problem is occurring because the procedures are in separate assemblies, not because they are in separate files. We will work on this and post here when we know more.

Don Johnson
01-12-2004, 09:35 PM
Any word on the status of this, by chance?

Lahey Support
01-12-2004, 11:20 PM
It looks like this will be fixed in the next release.