- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
I have been having difficulty getting an optional argument to work properly. I've got a Fortran written DLL with many passed arguments. The last two are optional...an integer and a real*8. If I do not pass along these two arguments to the DLL and examine what is received by the DLL, the integer is registered as ' Undefined pointer/array' and is correctly identified as .false. with a 'Present' command. The real, however, is registered as an 'Undefined address', and is incorrectly identified as .true. with a 'Present' command. I've tried much simpler test cases that do not use the DLL interface and they work fine. Is there something going wacky with the DLL? Everything is written in Fortran, so I'd think that the interface would be fairly simple...
コピーされたリンク
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
ummm....if they are optional and you do not pass them to the routine then in the routine they are undefined. which you are finding properly. Any additional tests on them would be if, and only if, they are defined. Since 'undefined' means who knows or cares what's in those placeholders?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
The placeholders, as identified when I pause the program to debug are different. The integer is 'Undefined pointer/array' while the real is 'Unidentified'. Apparently this difference matters to the compiler because it still thinks something was passed into the 'Unidentified' variable (even though nothing was). Very frustrating.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
If you have OPTIONAL arguments, an explicit interface to the procedure must be visible to the caller. Did you do this?
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Steve - I had not done that (hand smack upside the head). I'll give that a try and keep you posted. Thanks!
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Steve - Thanks, as always! I did not know that the otional arguments needed the interface, but it makes perfect sense. I've added the interface and everything works great.
- 新着としてマーク
- ブックマーク
- 購読
- ミュート
- RSS フィードを購読する
- ハイライト
- 印刷
- 不適切なコンテンツを報告
Normally, when the caller and callee are compiled in the same project, the default "Generated Interface Checking" feature would catch this, but if you had your DLL as a separate project and, obviously, didn't have a module defining the interface, you'd run into this problem.
I'll also recommend a read of Doctor Fortran Gets Explicit - Again!