<?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: printf on itanium2 in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957199#M788451</link>
    <description>thanks for help&lt;BR /&gt;bye</description>
    <pubDate>Mon, 06 Feb 2006 06:44:25 GMT</pubDate>
    <dc:creator>Wanda Canade'</dc:creator>
    <dc:date>2006-02-06T06:44:25Z</dc:date>
    <item>
      <title>printf on itanium2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957197#M788449</link>
      <description>we are migrating C programs from PA-RISC with operating system unix11.00 to itanium2 with operating system unix 11.23.&lt;BR /&gt;on itanium2 this printf:&lt;BR /&gt;printf("NOME &amp;lt;%s&amp;gt; &amp;lt;%s&amp;gt; &amp;lt;%s&amp;gt; &amp;lt;%s&amp;gt;\n", argv[0], ((argc == 4) ? argv[1], argv[2], argv[3] : "def1", "def2", "def3"));&lt;BR /&gt;&lt;BR /&gt;produce memory fault&lt;BR /&gt;Can help me?&lt;BR /&gt;thanks in advance</description>
      <pubDate>Fri, 03 Feb 2006 11:41:51 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957197#M788449</guid>
      <dc:creator>Wanda Canade'</dc:creator>
      <dc:date>2006-02-03T11:41:51Z</dc:date>
    </item>
    <item>
      <title>Re: printf on itanium2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957198#M788450</link>
      <description>I should hope that it produces a memory fault. You seem to have a misunderstanding of the comma operator in C and unlike in C++ it can't be overloaded. Essentially with commas the left assignments are thrown away and only the rightmost counts.&lt;BR /&gt;&lt;BR /&gt;Try something like this:&lt;BR /&gt;&lt;BR /&gt;int main(int argc, char *argv[])&lt;BR /&gt;{&lt;BR /&gt;  int i = -1;&lt;BR /&gt;  int j = -2;&lt;BR /&gt;&lt;BR /&gt;  i,j = (1,2,3);&lt;BR /&gt;  (void) printf("i = %d j = %d\n",i,j);&lt;BR /&gt;  return(i);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Without testing this, if C works like i think it does, the output should be:&lt;BR /&gt;i = -1 j = 3&lt;BR /&gt;&lt;BR /&gt;In your case, only 1 of the 3 pointers gets a value, the remaining arguments are whatever is on the stack (garbage).&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Fri, 03 Feb 2006 12:20:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957198#M788450</guid>
      <dc:creator>A. Clay Stephenson</dc:creator>
      <dc:date>2006-02-03T12:20:55Z</dc:date>
    </item>
    <item>
      <title>Re: printf on itanium2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957199#M788451</link>
      <description>thanks for help&lt;BR /&gt;bye</description>
      <pubDate>Mon, 06 Feb 2006 06:44:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957199#M788451</guid>
      <dc:creator>Wanda Canade'</dc:creator>
      <dc:date>2006-02-06T06:44:25Z</dc:date>
    </item>
    <item>
      <title>Re: printf on itanium2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957200#M788452</link>
      <description>I did a wee bit more than Clay did (I was wondering about this, I also read Usenet comp.lang.c) and tried this code:&lt;BR /&gt;&lt;BR /&gt;#include &lt;STDLIB.H&gt;&lt;BR /&gt;#include &lt;STDIO.H&gt;&lt;BR /&gt; &lt;BR /&gt;int main(void)&lt;BR /&gt;{&lt;BR /&gt;   int i = 0;&lt;BR /&gt;   int j = 1;&lt;BR /&gt;   int k = 2;&lt;BR /&gt;   int l = 3;&lt;BR /&gt; &lt;BR /&gt;   printf("%d %d %d %d\n", &lt;BR /&gt;     ((i == 0) ? k, j, l, i : l, k, i, j));&lt;BR /&gt; &lt;BR /&gt;    return (EXIT_SUCCESS);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;I compiled this one a rp2470 under 11i with the ANSI C HP compiler and it compiled okay, but the resultant output was '1 2097088492 134217759 3'.  About what I would expect.&lt;BR /&gt;&lt;BR /&gt;The same code, when compiled under gcc witht he -Wall flag on returns, on compile:&lt;BR /&gt;$ gcc -Wall one.c -o one&lt;BR /&gt;one.c: In function `main':&lt;BR /&gt;one.c:12: warning: left-hand operand of comma expression has no effect&lt;BR /&gt;one.c:12: warning: left-hand operand of comma expression has no effect&lt;BR /&gt;one.c:12: warning: left-hand operand of comma expression has no effect&lt;BR /&gt;one.c:12: warning: left-hand operand of comma expression has no effect&lt;BR /&gt;one.c:12: warning: left-hand operand of comma expression has no effect&lt;BR /&gt;one.c:12: warning: left-hand operand of comma expression has no effect&lt;BR /&gt;one.c:12: warning: too few arguments for format&lt;BR /&gt;&lt;BR /&gt;Actually, a few less errors than I expected, but.....&lt;BR /&gt;&lt;BR /&gt;Wanda, I think you have been extremely lucky if the code you posted actually returned the expected results when compiled with a C compiler.  I would recommend that all of the constructs like the one you posted be revised, personnally I would use something on the order of:&lt;BR /&gt;&lt;BR /&gt;printf("NOME &amp;lt;%s&amp;gt; ", argv[0]);&lt;BR /&gt;if (argc == 4)&lt;BR /&gt;    printf("&amp;lt;%s&amp;gt; &amp;lt;%s&amp;gt; &amp;lt;%s&amp;gt;\n", argv[1], argv[2], argv[3]);&lt;BR /&gt;else&lt;BR /&gt;    printf("&lt;DEF1&gt; &lt;DEF3&gt;\n");&lt;BR /&gt;&lt;BR /&gt;But then, the above is personnal coding style, of which arguments can lead to long threads in which nothing much is actually said or accomplished. It is also untested, and written off the top oif my head, so I might jhave made typo's in it.&lt;BR /&gt;&lt;BR /&gt;&lt;/DEF3&gt;&lt;/DEF1&gt;&lt;/STDIO.H&gt;&lt;/STDLIB.H&gt;</description>
      <pubDate>Mon, 06 Feb 2006 07:06:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957200#M788452</guid>
      <dc:creator>Tom Henning</dc:creator>
      <dc:date>2006-02-06T07:06:44Z</dc:date>
    </item>
    <item>
      <title>Re: printf on itanium2</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957201#M788453</link>
      <description>&amp;gt;&amp;gt; Wanda, I think you have been extremely lucky if the code you posted actually returned the expected results when compiled with a C compiler. &lt;BR /&gt;&lt;BR /&gt;Hmmm, I would have called that being 'UNlucky'.&lt;BR /&gt;It is so much easier to be told your code is broken when it is first written, and not much  later when there is a sea filled with red herrings to disguise the problem.&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Mon, 06 Feb 2006 07:12:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/printf-on-itanium2/m-p/4957201#M788453</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2006-02-06T07:12:15Z</dc:date>
    </item>
  </channel>
</rss>

