<?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 C interoperability, passing constants in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175783#M147353</link>
    <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am having trouble compiling the following code:&lt;/P&gt;&lt;P&gt;C code:&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/P&gt;&lt;P&gt;extern const int foo = -1;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Fortran code:&lt;/P&gt;&lt;P&gt;module cnst_m&lt;/P&gt;&lt;P&gt;&amp;nbsp; use, intrinsic :: iso_c_binding, only: c_int&lt;/P&gt;&lt;P&gt;&amp;nbsp; implicit none&lt;/P&gt;&lt;P&gt;&amp;nbsp; private&lt;/P&gt;&lt;P&gt;&amp;nbsp; public :: &amp;amp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOO&lt;/P&gt;&lt;P&gt;&amp;nbsp; integer(kind=c_int), bind(c), protected :: FOO&lt;/P&gt;&lt;P&gt;end module cnst_m&lt;/P&gt;&lt;P&gt;program cnst_p&lt;/P&gt;&lt;P&gt;&amp;nbsp; use cnst_m, only: FOO&lt;/P&gt;&lt;P&gt;&amp;nbsp; implicit none&lt;/P&gt;&lt;P&gt;&amp;nbsp; print *, FOO&lt;BR /&gt;&amp;nbsp; stop&lt;BR /&gt;end program cnst_p&lt;/P&gt;&lt;P&gt;When using the "-init=(minus_)huge" flag, the compiler returns:&lt;/P&gt;&lt;P&gt;/tmp/ifortSUJ720.o:(.data+0x0): multiple definition of `foo'&lt;BR /&gt;./cnst.o:(.rodata+0x0): first defined here&lt;/P&gt;&lt;P&gt;The problem is also present with real initialization.&lt;/P&gt;&lt;P&gt;I would wager this has something to do with the way default initialization is defined.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;José Rui&lt;/P&gt;</description>
    <pubDate>Mon, 07 Oct 2019 11:59:04 GMT</pubDate>
    <dc:creator>faustino_de_sousa__j</dc:creator>
    <dc:date>2019-10-07T11:59:04Z</dc:date>
    <item>
      <title>C interoperability, passing constants</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175783#M147353</link>
      <description>&lt;P&gt;Hi all!&lt;/P&gt;&lt;P&gt;I am having trouble compiling the following code:&lt;/P&gt;&lt;P&gt;C code:&lt;/P&gt;&lt;P&gt;#include &amp;lt;stdlib.h&amp;gt;&lt;/P&gt;&lt;P&gt;extern const int foo = -1;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Fortran code:&lt;/P&gt;&lt;P&gt;module cnst_m&lt;/P&gt;&lt;P&gt;&amp;nbsp; use, intrinsic :: iso_c_binding, only: c_int&lt;/P&gt;&lt;P&gt;&amp;nbsp; implicit none&lt;/P&gt;&lt;P&gt;&amp;nbsp; private&lt;/P&gt;&lt;P&gt;&amp;nbsp; public :: &amp;amp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; FOO&lt;/P&gt;&lt;P&gt;&amp;nbsp; integer(kind=c_int), bind(c), protected :: FOO&lt;/P&gt;&lt;P&gt;end module cnst_m&lt;/P&gt;&lt;P&gt;program cnst_p&lt;/P&gt;&lt;P&gt;&amp;nbsp; use cnst_m, only: FOO&lt;/P&gt;&lt;P&gt;&amp;nbsp; implicit none&lt;/P&gt;&lt;P&gt;&amp;nbsp; print *, FOO&lt;BR /&gt;&amp;nbsp; stop&lt;BR /&gt;end program cnst_p&lt;/P&gt;&lt;P&gt;When using the "-init=(minus_)huge" flag, the compiler returns:&lt;/P&gt;&lt;P&gt;/tmp/ifortSUJ720.o:(.data+0x0): multiple definition of `foo'&lt;BR /&gt;./cnst.o:(.rodata+0x0): first defined here&lt;/P&gt;&lt;P&gt;The problem is also present with real initialization.&lt;/P&gt;&lt;P&gt;I would wager this has something to do with the way default initialization is defined.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;José Rui&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 11:59:04 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175783#M147353</guid>
      <dc:creator>faustino_de_sousa__j</dc:creator>
      <dc:date>2019-10-07T11:59:04Z</dc:date>
    </item>
    <item>
      <title>Try with 'name=' option with</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175784#M147354</link>
      <description>&lt;P&gt;Try with 'name=' option with bind(C,):&lt;/P&gt;
&lt;PRE class="brush:fortran; class-name:dark;"&gt;integer(kind=c_int), bind(C, name="foo"), protected :: FOO !&amp;lt;-- Note name= option&lt;/PRE&gt;

&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 15:47:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175784#M147354</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2019-10-07T15:47:19Z</dc:date>
    </item>
    <item>
      <title>Makes no difference here.</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175785#M147355</link>
      <description>&lt;P&gt;Makes no difference here.&lt;/P&gt;&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;José Rui&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 16:20:54 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175785#M147355</guid>
      <dc:creator>faustino_de_sousa__j</dc:creator>
      <dc:date>2019-10-07T16:20:54Z</dc:date>
    </item>
    <item>
      <title>What happens if you do not</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175786#M147356</link>
      <description>&lt;P&gt;What happens if you do not define it in your C code:&lt;/P&gt;
&lt;PRE class="brush:cpp; class-name:dark;"&gt;extern const int foo;&lt;/PRE&gt;

&lt;P&gt;but do so in Fortran:&lt;/P&gt;

&lt;PRE class="brush:fortran; class-name:dark;"&gt;integer(c_int), bind(C, name="foo"), protected :: FOO = 1&lt;/PRE&gt;

&lt;P&gt;If this doesn't work, see if you can get help from Intel support.&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2019 17:17:00 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/C-interoperability-passing-constants/m-p/1175786#M147356</guid>
      <dc:creator>FortranFan</dc:creator>
      <dc:date>2019-10-07T17:17:00Z</dc:date>
    </item>
  </channel>
</rss>

