<?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: Calling vararg functions from Fortran? in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749772#M6569</link>
    <description>It is my understanding that a vararg call actually passes an array with a count that has the ... arguments. There is no direct support for this from Fortran, but you may be able to hack something. It was not a goal of Fortran's C interoperability feature to support all possible C interfaces.&lt;BR /&gt;</description>
    <pubDate>Mon, 18 Aug 2008 15:54:27 GMT</pubDate>
    <dc:creator>Steven_L_Intel1</dc:creator>
    <dc:date>2008-08-18T15:54:27Z</dc:date>
    <item>
      <title>Calling vararg functions from Fortran?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749771#M6568</link>
      <description>This might really be a questioon for a C forum, but maybe someone working on ISO_C_BINDING has already considered this.&lt;BR /&gt;&lt;BR /&gt;Fortran cannot easily call functions with variable argument lists, but I am wondering if it works in practice to call such functions with the variable argument part excluded. Is calling a vararg function with no extra arguments the same as calling an function with the same prototype without the final ellipsis, as long as it also uses the standard __cdecl calling convention? ISO_C_BINDING specifically excludes vararg functions, but maybe that is only because some systems use a non-standard calling convention, like MS-Windows STDCALL, or because the don't want to support the var-arg part?&lt;BR /&gt;&lt;BR /&gt;If so, maybe it is reliable to prototype a C vararg function as an equivalent non-vararg function using ISO_C_BINDING, as long as there is some way to ensure that it uses the __cdecl convention, such as !DEC$ attribute extensions on Windows. It is simple enough to write a C wrapper, but it would be nice to call directly and avoid the C code, if possible.&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Aug 2008 15:21:56 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749771#M6568</guid>
      <dc:creator>joseph-krahn</dc:creator>
      <dc:date>2008-08-18T15:21:56Z</dc:date>
    </item>
    <item>
      <title>Re: Calling vararg functions from Fortran?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749772#M6569</link>
      <description>It is my understanding that a vararg call actually passes an array with a count that has the ... arguments. There is no direct support for this from Fortran, but you may be able to hack something. It was not a goal of Fortran's C interoperability feature to support all possible C interfaces.&lt;BR /&gt;</description>
      <pubDate>Mon, 18 Aug 2008 15:54:27 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749772#M6569</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-18T15:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Calling vararg functions from Fortran?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749773#M6570</link>
      <description>My goal ios to call varargs without the extra arguments. In most cases, varargs is a string formatting convenience, and a Fortran caller can just do an internal write, then pass a pre-formatted string, as long as it has no printf syntax.&lt;BR /&gt;&lt;BR /&gt;For stack-based compilers, var-arg is just a standard call, except that the caller optionally pushes extra arguments onto the stack. The inital set of arguments is the same as a regular C call. So, if no extra arguments are added, it works just like a C prototype without the "...". What I don't know is whether that is required for the CDECL calling convention, or if this just works for typical stack-based hardware.&lt;BR /&gt;&lt;BR /&gt;I'll post this question to the C forum.&lt;BR /&gt;</description>
      <pubDate>Tue, 19 Aug 2008 16:42:07 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749773#M6570</guid>
      <dc:creator>joseph-krahn</dc:creator>
      <dc:date>2008-08-19T16:42:07Z</dc:date>
    </item>
    <item>
      <title>Re: Calling vararg functions from Fortran?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749774#M6571</link>
      <description>I think you will find, when you post on the C forum, that your understanding of vararg is incorrect. &lt;BR /&gt;</description>
      <pubDate>Tue, 19 Aug 2008 17:32:52 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749774#M6571</guid>
      <dc:creator>Steven_L_Intel1</dc:creator>
      <dc:date>2008-08-19T17:32:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calling vararg functions from Fortran?</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749775#M6572</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;DIV&gt;&lt;IMG src="https://community.intel.com/file/6745" /&gt; &lt;STRONG&gt;MADsblionel:&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;I think you will find, when you post on the C forum, that your understanding of vararg is incorrect. &lt;BR /&gt;&lt;/DIV&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt;I think that passing an argument array, as you mentioned, is what happens when passing a "va_list" argument, which is different than "...".&lt;BR /&gt;&lt;BR /&gt;Also, I forgot that "vararg" is the old interface, and "stdarg" is the new interface to variable argument lists. Maybe vararg does pass arguments the same as va_list?&lt;BR /&gt;&lt;BR /&gt;Just to verify that stdarg does push extra arguments onto the stack, I compiled the following C test code, which is compiled in two parts via an #ifdef, to avoid a conflicting type error:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt;#include &lt;STDARG.H&gt;&lt;BR /&gt;#ifdef MAIN&lt;BR /&gt;void test(int a,...);&lt;BR /&gt;int main(int argc, char *argv[]) {&lt;BR /&gt; test(1,2,3,4);&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;BR /&gt;#else&lt;BR /&gt;void test(int a, int b, int c, int d) {&lt;BR /&gt; printf("%d,%d,%d,%d
",a,b,c,d);&lt;BR /&gt;}&lt;BR /&gt;#endif&lt;BR /&gt;&lt;BR /&gt;When run, I get:&lt;BR /&gt;1,2,3,4&lt;BR /&gt;&lt;BR /&gt;Even though it happens to work on Linux, that doesn't mean that CDECL is required to work that way.&lt;BR /&gt;&lt;BR /&gt;I suppose that even if CDECL does ensure that this works, it is still a hack, and it is really better just to have a C wrapper function.&lt;BR /&gt;&lt;/STDARG.H&gt;&lt;/STDIO.H&gt;</description>
      <pubDate>Thu, 21 Aug 2008 15:57:31 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Calling-vararg-functions-from-Fortran/m-p/749775#M6572</guid>
      <dc:creator>joseph-krahn</dc:creator>
      <dc:date>2008-08-21T15:57:31Z</dc:date>
    </item>
  </channel>
</rss>

