Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #91648
| Path | csiph.com!news.mixmin.net!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
| Newsgroups | comp.lang.c++ |
| Subject | Re: Problem with calling C++ from Fortran |
| Date | Sun, 10 Sep 2023 14:22:12 +0100 |
| Organization | A noiseless patient Spider |
| Lines | 48 |
| Message-ID | <87o7iajh8b.fsf@bsb.me.uk> (permalink) |
| References | <udhbs9$e5d$1@dont-email.me> <udhcaj$j8l$1@dont-email.me> <udkdu9$itm4$1@dont-email.me> |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Injection-Info | dont-email.me; posting-host="871ee901e005cd01e5d2484bc26cd51b"; logging-data="629398"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18Lnv2oezsOVhuVR2TXssue5iGEy4++eis=" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
| Cancel-Lock | sha1:BIh4NBbjzpHEndeqLNqqx84r4uw= sha1:CGn93J3JDeLS63q6BxnVCJKAwDU= |
| X-BSB-Auth | 1.344564da97a02fed77b0.20230910142212BST.87o7iajh8b.fsf@bsb.me.uk |
| Xref | csiph.com comp.lang.c++:91648 |
Show key headers only | View raw
db <dieterhansbritz@gmail.com> writes:
> On 09.09.2023 11.02, Muttley@dastardlyhq.com wrote:
>> On Sat, 9 Sep 2023 10:54:33 +0200
>> db <dieterhansbritz@gmail.com> wrote:
>>> but now it says that C-double doesn't exist.
>>>
>>> Any ideas?
>> C++ mangles function names so that the name you give the function isn't
>> the
>> name the dynamic loader sees in the binary. You need to put this around whatever
>> function you want to call from Fortran so it has C style linkage which means
>> the name remains the same:
>> extern "C" {
>> void calledFromFortran()
>> {
>> :
>> }
>> }
>>
> Where should this go in the code? I added it at the end as is,
> and now I get this:
>
> ~/ownlib90/tests> ./jbandtest
> jband.cpp:88:1: error: expected initializer before 'extern'
> 88 | extern "C" {
> | ^~~~~~
> jband.cpp:96:1: error: expected unqualified-id before '{' token
> 96 | {
> | ^
> jband.cpp: In function 'void calledFromFortran()':
> jband.cpp:350:9: error: expected primary-expression before ':' token
> 350 | :
> ...
You are giving people very little to go on. There's an unknown command
(./jbandtest) the gives some errors where only one line of code can be
seen.
Can you produce a cut-down version to the program that shows the same
error -- mimimal example of the C++ and of the Fortran that should
calls it but which fails? That would mean you could post the code.
If that is not possible, can you link to the source so those who know
both C++ and Fortran can take a proper look?
--
Ben.
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-09 10:54 +0200
Re: Problem with calling C++ from Fortran Muttley@dastardlyhq.com - 2023-09-09 09:02 +0000
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-09 12:47 +0200
Re: Problem with calling C++ from Fortran Muttley@dastardlyhq.com - 2023-09-09 10:51 +0000
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-09 12:52 +0200
Re: Problem with calling C++ from Fortran Muttley@dastardlyhq.com - 2023-09-09 11:00 +0000
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-10 14:33 +0200
Re: Problem with calling C++ from Fortran Paavo Helde <eesnimi@osa.pri.ee> - 2023-09-10 18:49 +0300
Re: Problem with calling C++ from Fortran Muttley@dastardlyhq.com - 2023-09-11 08:23 +0000
Re: Problem with calling C++ from Fortran Paavo Helde <eesnimi@osa.pri.ee> - 2023-09-09 16:56 +0300
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-10 14:36 +0200
Re: Problem with calling C++ from Fortran James Kuyper <jameskuyper@alumni.caltech.edu> - 2023-09-11 00:14 -0400
Re: Problem with calling C++ from Fortran Bo Persson <bo@bo-persson.se> - 2023-09-10 16:08 +0200
Re: Problem with calling C++ from Fortran "Alf P. Steinbach" <alf.p.steinbach@gmail.com> - 2023-09-09 16:30 +0200
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-10 14:48 +0200
Re: Problem with calling C++ from Fortran Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-09-10 14:22 +0100
Re: Problem with calling C++ from Fortran Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-09-10 17:27 +0100
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-11 14:00 +0200
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-11 05:21 -0700
Re: Problem with calling C++ from Fortran Muttley@dastardlyhq.com - 2023-09-11 13:33 +0000
Re: Problem with calling C++ from Fortran Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-09-12 00:26 +0100
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-12 10:48 +0200
Re: Problem with calling C++ from Fortran Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-09-12 14:14 +0100
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-12 07:15 -0700
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-12 02:00 -0700
Re: Problem with calling C++ from Fortran Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-09-12 14:22 +0100
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-12 07:32 -0700
Re: Problem with calling C++ from Fortran db <dieterhansbritz@gmail.com> - 2023-09-12 18:36 +0200
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-19 02:39 -0700
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-10 08:38 -0700
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-10 09:51 -0700
Re: Problem with calling C++ from Fortran Michael S <already5chosen@yahoo.com> - 2023-09-11 02:49 -0700
Buy Zen Mushroom Chocolate Bar Microdose "https://psychedelicminds.shop/" <psychedelicsmind@gmail.com> - 2023-09-11 05:14 -0700
csiph-web