[CMake] Fortran-C mixed code (possible solution)
Radu Serban
radu at llnl.gov
Wed Jan 24 11:18:15 EST 2007
Arjen Markus wrote:
> Radu Serban wrote:
>
>>
>>
>> I've added this to my implementation (attached to this message). If
>> successful, the name mangling scheme is encoded in two (cached,
>> internal) variables: SCHEME_NO_UNDERSCORES is the mangled name of the
>> symbol "mysub" and SCHEME_WITH_UNDERSCORES is the mangled name of the
>> symbol "my_sub". The way I use them is by further defining two
>> substitution variables which I use to generate a configuration header
>> (using CONFIGURE_FILE). These variables (DEFINE_F77_FUNC and
>> DEFINE_F77_FUNC_) contain the #define lines for two C preprocessor
>> macros, F77_FUNC and F77_FUNC_ which can then be used in the C code.
>> As an example, using the GNU compilers (without any of the g77 flags
>> you mention) these two macros will be:
>> #define F77_FUNC(name,NAME) name ## _
>> #define F77_FUNC_(name,NAME) name ## __
>>
>> I've tested this with the GNU compilers (with and without the flags
>> you mentioned), as well as with PGI and Intel compilers (all under
>> Linux). I hope it's portable but, unfortunately, I don't have a
>> Windows machine to try it on...
>>
> Hi Radu,
>
> I took a look at this new version of the script. It seems indeed more
> portable than
> the first version, but I must warn you that there are a few other issues
> on Windows
> that you need to take care of (there is the matter of the calling
> convention, indicated
> by the special keyword stdcall__ or the like and the positioning of the
> implicit
> string length argument). I am not sure how these can be automatically
> determined.
>
> Regards,
>
> Arjen
>
Hi Arjen,
I did not intend to solve all problems associated with mixing Fortran and C :-).
Precisely due to portability issues, we kept the Fortran interfaces to our
solvers fairly basic (e.g. we impose fixed subroutine names and therefore we do
not have to deal with issues related to passing function names and/or strings
between Fortran and C which are problematic on any platforms, not only Windows).
As such, I'm only interested in finding the name mangling scheme which I hope to
do with the script I posted previously.
Thanks,
--Radu
More information about the CMake
mailing list