<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Problem calling C++ from Fortran in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893846#M79093</link>
    <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/428845"&gt;ferrad02&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;I have built a library (under VC2005) containing a fucntion I wish to call from Fortran:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;However I get an exception when it tries to go into the C++ function. Any idea what I'm doing wrong?&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;When it just &lt;EM&gt;tries&lt;/EM&gt;, or does it actually enter the C function? What happens in the debugger?&lt;BR /&gt;&lt;BR /&gt;I don't see anything wrong in the declarations you posted, but they tell just a small part of the story.&lt;BR /&gt;</description>
    <pubDate>Thu, 28 May 2009 06:55:22 GMT</pubDate>
    <dc:creator>Jugoslav_Dujic</dc:creator>
    <dc:date>2009-05-28T06:55:22Z</dc:date>
    <item>
      <title>Problem calling C++ from Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893845#M79092</link>
      <description>I have built a library (under VC2005) containing a fucntion I wish to call from Fortran:&lt;BR /&gt;&lt;BR /&gt;extern "C" {&lt;BR /&gt;int cdecl Run_Great() {&lt;BR /&gt;... snipped ...&lt;BR /&gt;}&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I include the lib in my Fortran project (Intel 10.1) and am trying to call it with this code:&lt;BR /&gt;&lt;BR /&gt;program RunGreat&lt;BR /&gt;implicit none&lt;BR /&gt;&lt;BR /&gt;interface&lt;BR /&gt;integer function Run_Great()&lt;BR /&gt;!dec$ attributes C ,alias : '_Run_Great' :: Run_Great&lt;BR /&gt;end function Run_Great&lt;BR /&gt;end interface&lt;BR /&gt;&lt;BR /&gt;integer i&lt;BR /&gt;i = Run_Great()&lt;BR /&gt;&lt;BR /&gt;end program RunGreat&lt;BR /&gt;&lt;BR /&gt;However I get an exception when it tries to go into the C++ function. Any idea what I'm doing wrong?&lt;BR /&gt;&lt;BR /&gt;ferrad</description>
      <pubDate>Wed, 27 May 2009 15:20:48 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893845#M79092</guid>
      <dc:creator>ferrad02</dc:creator>
      <dc:date>2009-05-27T15:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problem calling C++ from Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893846#M79093</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="width: 100%; margin-top: 5px;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/428845"&gt;ferrad02&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;I have built a library (under VC2005) containing a fucntion I wish to call from Fortran:&lt;BR /&gt;&lt;BR /&gt;...&lt;BR /&gt;&lt;BR /&gt;However I get an exception when it tries to go into the C++ function. Any idea what I'm doing wrong?&lt;BR /&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;When it just &lt;EM&gt;tries&lt;/EM&gt;, or does it actually enter the C function? What happens in the debugger?&lt;BR /&gt;&lt;BR /&gt;I don't see anything wrong in the declarations you posted, but they tell just a small part of the story.&lt;BR /&gt;</description>
      <pubDate>Thu, 28 May 2009 06:55:22 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893846#M79093</guid>
      <dc:creator>Jugoslav_Dujic</dc:creator>
      <dc:date>2009-05-28T06:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: Problem calling C++ from Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893847#M79094</link>
      <description>&lt;DIV style="margin:0px;"&gt;
&lt;DIV id="quote_reply" style="margin-top: 5px; width: 100%;"&gt;
&lt;DIV style="margin-left:2px;margin-right:2px;"&gt;Quoting - &lt;A href="https://community.intel.com/en-us/profile/391180"&gt;Jugoslav Dujic&lt;/A&gt;&lt;/DIV&gt;
&lt;DIV style="background-color:#E5E5E5; padding:5px;border: 1px; border-style: inset;margin-left:2px;margin-right:2px;"&gt;&lt;EM&gt;&lt;BR /&gt;When it just &lt;EM&gt;tries&lt;/EM&gt;, or does it actually enter the C function? What happens in the debugger?&lt;BR /&gt;&lt;BR /&gt;I don't see anything wrong in the declarations you posted, but they tell just a small part of the story.&lt;BR /&gt;&lt;/EM&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;BR /&gt;If I put a break on the Fortran call "i=Run_Great()", It stops there just fine. When I "Step Into", it waits for a second or so, then pops up a window which says:&lt;BR /&gt;&lt;BR /&gt;Unhandled exception at 0x00a6d628 (msvcr80d.dll) in console1.exe: &lt;BR /&gt;0xC0000005: Access violation reading location 0x00000031.&lt;BR /&gt;&lt;BR /&gt;It brings up the code for memcpy.asm, line 314:&lt;BR /&gt;&lt;BR /&gt;UnwindUp3:&lt;BR /&gt;mov eax,[esi+ecx*4-12] ;U(entry)/V(not) - get dword from source&lt;BR /&gt;;V(entry) - spare&lt;BR /&gt;&lt;BR /&gt;The call stack is:&lt;BR /&gt;&lt;BR /&gt;&amp;gt; msvcr80d.dll!memcpy(unsigned char * dst=0x003d8790, unsigned char * src=0x00000031, unsigned long count=15) Line 314 Asm&lt;BR /&gt;msvcr80d.dll!memcpy_s(void * dst=0x003d8790, unsigned int sizeInBytes=15, const void * src=0x00000031, unsigned int count=15) Line 67 + 0x11 bytes C&lt;BR /&gt;msvcp80d.dll!std::char_traits&lt;CHAR&gt;::_Copy_s(char * _First1=0x003d8790, unsigned int _Size_in_bytes=15, const char * _First2=0x00000031, unsigned int _Count=15) Line 575 + 0x16 bytes C++&lt;BR /&gt;msvcp80d.dll!std::_Traits_helper::copy_s&lt;:CHAR_TRAITS&gt;&lt;CHAR&gt; &amp;gt;(char * _First1=0x003d8790, unsigned int _Size=15, const char * _First2=0x00000031, unsigned int _Count=15, std::_Secure_char_traits_tag __formal={...}) Line 707 + 0x15 bytes C++&lt;BR /&gt;msvcp80d.dll!std::_Traits_helper::copy_s&lt;:CHAR_TRAITS&gt;&lt;CHAR&gt; &amp;gt;(char * _First1=0x003d8790, unsigned int _Size=15, const char * _First2=0x00000031, unsigned int _Count=15) Line 699 + 0x21 bytes C++&lt;BR /&gt;msvcp80d.dll!std::basic_string&lt;CHAR&gt;,std::allocator&lt;CHAR&gt; &amp;gt;::assign(const std::basic_string&lt;CHAR&gt;,std::allocator&lt;CHAR&gt; &amp;gt; &amp;amp; _Right=&lt;BAD ptr=""&gt;, unsigned int _Roff=0, unsigned int _Count=4294967295) Line 1059 + 0x25 bytes C++&lt;BR /&gt;msvcp80d.dll!std::basic_string&lt;CHAR&gt;,std::allocator&lt;CHAR&gt; &amp;gt;::basic_string&lt;CHAR&gt;,std::allocator&lt;CHAR&gt; &amp;gt;(const std::basic_string&lt;CHAR&gt;,std::allocator&lt;CHAR&gt; &amp;gt; &amp;amp; _Right=&lt;BAD ptr=""&gt;) Line 733 C++&lt;BR /&gt;libgreatd.dll!101a5833() &lt;BR /&gt;[Frames below may be incorrect and/or missing, no symbols loaded for libgreatd.dll] &lt;BR /&gt;libgreatd.dll!10195331() &lt;BR /&gt;libgreatd.dll!103926d2() &lt;BR /&gt;console1.exe!_Run_Great() + 0x20f bytes C++&lt;BR /&gt;ntdll.dll!7c92770a() &lt;BR /&gt;ntdll.dll!7c94b1b0() &lt;BR /&gt;console1.exe!__set_flsgetvalue() Line 288 + 0xc bytes C&lt;BR /&gt;console1.exe!write_string(char * string=0x00000000, int len=2089914145, _iobuf * f=0x00000000, int * pnumwritten=0x00000000) Line 2570 + 0xd bytes C++&lt;BR /&gt;ntdll.dll!7c91930f() &lt;BR /&gt;kernel32.dll!7c80ba4d() &lt;BR /&gt;ntdll.dll!7c91930f() &lt;BR /&gt;ntdll.dll!7c918f21() &lt;BR /&gt;ntdll.dll!7c9101db() &lt;BR /&gt;console1.exe!_VEC_memzero(void * dst=0x50000061, int val=2600, int len=1244984) + 0x36 bytes C&lt;BR /&gt;ntdll.dll!7c94bc4c() &lt;BR /&gt;console1.exe!___intel_new_proc_init.H() + 0x20 bytes &lt;BR /&gt;console1.exe!_for__reentrancy_init() + 0x1e bytes &lt;BR /&gt;console1.exe!RUNGREAT() Line 15 + 0x5 bytes Fortran&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;LISTDLLS on console1.exe gives:&lt;BR /&gt;&lt;BR /&gt;D:GREATACFtestConsole1Debug&amp;gt;listdlls console1.exe&lt;BR /&gt;&lt;BR /&gt;ListDLLs V2.23 - DLL lister for Win9x/NT&lt;BR /&gt;Copyright (C) 1997-2000 Mark Russinovich&lt;BR /&gt;&lt;A href="http://www.sysinternals.com" target="_blank"&gt;http://www.sysinternals.com&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;------------------------------------------------------------------------------&lt;BR /&gt;console1.exe pid: 2408&lt;BR /&gt;Command line: "d:GREATACFtestConsole1debugconsole1.exe"&lt;BR /&gt;&lt;BR /&gt;Base Size Version Path&lt;BR /&gt;0x00400000 0xa6000 d:GREATACFtestConsole1debugconsole1.exe&lt;BR /&gt;0x7c900000 0xb2000 5.01.2600.5755 C:WINDOWSsystem32ntdll.dll&lt;BR /&gt;0x7c800000 0xf6000 5.01.2600.5512 C:WINDOWSsystem32kernel32.dll&lt;BR /&gt;0x10000000 0x4a3000 2.01.0002.0000 d:GREATACFtestConsole1debuglibgreatd.dll&lt;BR /&gt;0x004b0000 0x325000 d:GREATACFtestConsole1debugSlb.Ecl.Core.PVT.Toolboxd.dll&lt;BR /&gt;0x6eed0000 0x7e000 6.06.0893.0101 C:WINDOWSsystem32DFORMD.DLL&lt;BR /&gt;0x77c10000 0x58000 7.00.2600.5512 C:WINDOWSsystem32MSVCRT.dll&lt;BR /&gt;0x00350000 0x42000 d:GREATACFtestConsole1debugSlb.Ecl.Core.GradientOptimizerd.dll&lt;BR /&gt;0x007e0000 0xbc000 7.10.3077.0000 C:WINDOWSsystem32MSVCP71D.dll&lt;BR /&gt;0x008a0000 0x87000 7.10.3077.0000 C:WINDOWSsystem32MSVCR71D.dll&lt;BR /&gt;0x00930000 0xfe000 8.00.50727.0762 C:WINDOWSWinSxSx86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9fMSVCP80D.dll&lt;BR /&gt;0x00a30000 0x121000 8.00.50727.0762 C:WINDOWSWinSxSx86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9fMSVCR80D.dll&lt;BR /&gt;0x76c90000 0x28000 5.01.2600.5512 C:WINDOWSsystem32imagehlp.dll&lt;BR /&gt;0x003f0000 0xf000 10.01.0105.0105 C:Program FilesIntelCompilerFortran10.1.021IA32Bin1033ifcore_msg.dll&lt;BR /&gt;0x00c60000 0x5000 10.01.0105.0105 C:Program FilesIntelCompilerFortran10.1.021IA32Bin1033irc_msg.dll&lt;BR /&gt;0x59a60000 0xa1000 5.01.2600.5512 C:WINDOWSsystem32DBGHELP.dll&lt;BR /&gt;0x77c00000 0x8000 5.01.2600.5512 C:WINDOWSsystem32VERSION.dll&lt;BR /&gt;0x77dd0000 0x9b000 5.01.2600.5755 C:WINDOWSsystem32ADVAPI32.dll&lt;BR /&gt;0x77e70000 0x92000 5.01.2600.5512 C:WINDOWSsystem32RPCRT4.dll&lt;BR /&gt;0x77fe0000 0x11000 5.01.2600.5512 C:WINDOWSsystem32Secur32.dll&lt;BR /&gt;&lt;BR /&gt;Let me know if there is anything else I can provide to help diagnose the issue.&lt;/BAD&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/BAD&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/CHAR&gt;&lt;/:CHAR_TRAITS&gt;&lt;/CHAR&gt;&lt;/:CHAR_TRAITS&gt;&lt;/CHAR&gt;</description>
      <pubDate>Thu, 28 May 2009 07:14:28 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893847#M79094</guid>
      <dc:creator>ferrad02</dc:creator>
      <dc:date>2009-05-28T07:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem calling C++ from Fortran</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893848#M79095</link>
      <description>&lt;DIV style="margin:0px;"&gt;The problem is in the code I snipped: when this is removed, it works fine. The snipped code contains a call to a DLL which obviously is the cause, I will pursue that. Thanks.&lt;/DIV&gt;</description>
      <pubDate>Thu, 28 May 2009 10:36:16 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Problem-calling-C-from-Fortran/m-p/893848#M79095</guid>
      <dc:creator>ferrad02</dc:creator>
      <dc:date>2009-05-28T10:36:16Z</dc:date>
    </item>
  </channel>
</rss>

