Re: Accessing C++ function with Mixed Upper/Lower case name from F90 subroutine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Hello Glenn,

En/na Glenn H Sembroski ha escrit:
> Hi,
>   I have a problem trying to prepare a large simulation package, using
> mixed F90 and C++ routines, to compile and build under GCC (g++, and
> gfortran).  The problem is I have a C++ function: Gauss() which is
> called from an F90 routine:
>   x=gauss()
> 
> This package was made able to  build under the Intel fortran compiler by
> adding to the fortran file the Intel compile directive:
> 
> !DEC$ ATTRIBUTES ALIAS:'Gauss' :: gauss
> 
> I attempted to build this program using GCC  where for F90 code the
> gfortran compiler option -fno-underscoring was used.
> 
> Presently my fortran routine won't build. It gets the error:
> 
> 485: undefined reference to `gauss'
> 
> So, my question is, is there a way in GCC to enable the linker to find
> the C++  'Gauss' method?

  I don't know if the linker supports for this directly. But you can try
with the function attribute 'alias("target")' which is documented in
[1]. It creates a new name for the same routine, so you can call it
through the two names (the original, and the aliased).
  In your case, you should define in your C++ file an alias to "Gauss"
which is called "gauss".

  Besides, IIRC, ICC also supports this function attribute, so you
should be able to apply it transparently.

[1] http://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html

Regards.

> Thanks,
> Dr. Glenn Sembroski
> Physics Dept.,Purdue University
> sembrosk@xxxxxxxxxx
> 

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)

iEYEARECAAYFAkuyJs4ACgkQwMPeuqUCg9wTcQCffv1P6zfesFqNNB5IAfQc8JV8
1mAAnjz0pzkWaOSYUsox1t0+rqUqqdah
=c9fe
-----END PGP SIGNATURE-----

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux