<?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: strangeness with getenv() in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058236#M491263</link>
    <description>&lt;P&gt;&amp;gt; [...] I've confirmed that I checked that box now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Some other-company Lithium forums are configured to pre-check that&lt;BR /&gt;box, but not these HPE ones, it seems.&amp;nbsp; Complain here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="https://community.hpe.com/t5/x/bd-p/community-feedback-suggestions" target="_blank"&gt;https://community.hpe.com/t5/x/bd-p/community-feedback-suggestions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;gt; [...] I have confirmed that the code I am compiling is using the&lt;BR /&gt;&amp;gt; correct spelling: [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Ok.&lt;/P&gt;&lt;P&gt;&amp;gt; The man page for getenv() states [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I'd bet that it also mentions "#include &amp;lt;stdlib.h&amp;gt;".&amp;nbsp; If you omit&lt;BR /&gt;that, then you won't have a proper declaration of getenv(), and you'll&lt;BR /&gt;get the implicit type "int".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I don't have a real-money HP[E] C compiler, only an old GCC (and on&lt;BR /&gt;IA64, too), but around here, without the &amp;lt;stdlib.h&amp;gt;, I get a similar&lt;BR /&gt;complaint:&lt;/P&gt;&lt;P&gt;dyi $ gcc -c getnenv.c&lt;BR /&gt;getnenv.c: In function 'my_test_function':&lt;BR /&gt;getnenv.c:8: warning: assignment makes pointer from integer without a cast&lt;BR /&gt;dyi $&lt;/P&gt;&lt;P&gt;_With_ "#include &amp;lt;stdlib.h&amp;gt;", all is quiet:&lt;/P&gt;&lt;P&gt;dyi $ gcc -c getnenv_d.c&lt;BR /&gt;dyi $&lt;/P&gt;&lt;P&gt;dyi $ diff getnenv.c getnenv_d.c&lt;BR /&gt;1a2&lt;BR /&gt;&amp;gt; #include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;dyi $&lt;/P&gt;&lt;P&gt;dyi $ gcc -v&lt;BR /&gt;Using built-in specs.&lt;BR /&gt;Target: ia64-hp-hpux11.31&lt;BR /&gt;Configured with: ../gcc-4.3.3/configure&lt;BR /&gt;Thread model: posix&lt;BR /&gt;gcc version 4.3.3 (GCC)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; On a VMS system, you get more help (by default):&lt;/P&gt;&lt;P&gt;its $ cc getnenv&lt;/P&gt;&lt;P&gt;my_path_var = getenv("PATH");&lt;BR /&gt;.................^&lt;BR /&gt;%CC-I-IMPLICITFUNC, In this statement, the identifier "getenv" is implicitly dec&lt;BR /&gt;lared as a function.&lt;BR /&gt;at line number 8 in file ITS$DKA0:[SMS.itrc]getnenv.c;2&lt;/P&gt;&lt;P&gt;my_path_var = getenv("PATH");&lt;BR /&gt;...^&lt;/P&gt;&lt;P&gt;%CC-W-CVTDIFTYPES, In this statement, "getenv(...)" of type "int", is being conv&lt;BR /&gt;erted to "pointer to char".&lt;BR /&gt;at line number 8 in file ITS$DKA0:[SMS.itrc]getnenv.c;2&lt;BR /&gt;its $&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Or, on a Mac:&lt;/P&gt;&lt;P&gt;pro3$ cc -c getnenv.c&lt;BR /&gt;getnenv.c:8:18: warning: implicit declaration of function 'getenv' is invalid in&lt;BR /&gt;C99 [-Wimplicit-function-declaration]&lt;BR /&gt;my_path_var = getenv("PATH");&lt;BR /&gt;^&lt;BR /&gt;getnenv.c:8:16: warning: incompatible integer to pointer conversion assigning to&lt;BR /&gt;'char *' from 'int' [-Wint-conversion]&lt;BR /&gt;my_path_var = getenv("PATH");&lt;BR /&gt;^ ~~~~~~~~~~~~~~&lt;BR /&gt;2 warnings generated.&lt;BR /&gt;pro3$&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Of course, with "#include &amp;lt;stdlib.h&amp;gt;", everyone's happy:&lt;/P&gt;&lt;P&gt;its $ cc getnenv_d&lt;BR /&gt;its $&lt;/P&gt;&lt;P&gt;its $ cc /version&lt;BR /&gt;HP C V7.3-020 on OpenVMS IA64 V8.4&lt;/P&gt;&lt;P&gt;pro3$ cc -c getnenv_d.c&lt;BR /&gt;pro3$&lt;/P&gt;&lt;P&gt;pro3$ cc -v&lt;BR /&gt;Apple LLVM version 8.0.0 (clang-800.0.42.1)&lt;BR /&gt;Target: x86_64-apple-darwin15.6.0&lt;BR /&gt;Thread model: posix&lt;BR /&gt;InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/&lt;BR /&gt;XcodeDefault.xctoolchain/usr/bin&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; One of the problems with trying to debug a code fragment, is that&lt;BR /&gt;it's a code fragment, not an actual test case.&lt;/P&gt;</description>
    <pubDate>Fri, 09 Aug 2019 20:34:50 GMT</pubDate>
    <dc:creator>Steven Schweda</dc:creator>
    <dc:date>2019-08-09T20:34:50Z</dc:date>
    <item>
      <title>strangeness with getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058104#M491260</link>
      <description>&lt;P&gt;Hello again.&amp;nbsp; HP-UX 11.31, running on PA-RISC.&lt;/P&gt;&lt;P&gt;I have a C program that executes a call to getenv(), and either I'm misreading/misunderstanding the docs, or something isn't working right.&amp;nbsp; The code I'm working with is:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;int my_test_function(char *program)
{

    char *my_path_var;
    . . .
   my_path_var = getnenv("PATH");
    printf("The current path for my process it %s\n", my_path_var);
    . . .
}&lt;/LI-CODE&gt;&lt;P&gt;If I compile it using 'cc -o my_pgm my_pgm.c', I get an error:&lt;/P&gt;&lt;P&gt;&lt;FONT face="courier new,courier" size="2"&gt;cc: "my_pgm.c", line 431: warning 527: Integral value implicitly converted to pointer in assignment.&lt;/FONT&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But if I cast the result of getenv():&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;int my_test_function(char *program)
{

    char *my_path_var;
    . . .
   my_path_var = (char *)getnenv("PATH");
    printf("The current path for my process it %s\n", my_path_var);
    . . .
}&lt;/LI-CODE&gt;&lt;P&gt;the program compiles with no warnings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The man page for getenv() states that the function returns a character pointer, and I'm trying to assign it to a variable that is defined as a character pointer.&amp;nbsp; So why do I have to explicitly cast the result to character pointer?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 22:26:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058104#M491260</guid>
      <dc:creator>savage54</dc:creator>
      <dc:date>2019-08-08T22:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: strangeness with getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058120#M491261</link>
      <description>&lt;P&gt;&amp;gt; [...] HP-UX 11.31, running on PA-RISC.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Which C compiler?&lt;/P&gt;&lt;P&gt;&amp;gt; &amp;nbsp;&amp;nbsp; my_path_var = getnenv("PATH");&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Have you tried spelling "getenv" correctly?&lt;/P&gt;&lt;P&gt;&amp;gt; cc: "my_pgm.c", line 431: warning 527: Integral value implicitly&lt;BR /&gt;&amp;gt; converted to pointer in assignment.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Is that the only complaint that you get?&amp;nbsp; I'd expect something about&lt;BR /&gt;an implicit declaration of "getnenv()" (which, lacking an explicit&lt;BR /&gt;declaration, would be treated as type "int").&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I'd also expect a complaint at link time.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 05:04:10 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058120#M491261</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2019-08-09T05:04:10Z</dc:date>
    </item>
    <item>
      <title>Re: strangeness with getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058232#M491262</link>
      <description>&lt;P&gt;Sorry I didn't reply sooner.&amp;nbsp; I neglected to click the "Email me" box, so I wasn't notified that there was a response.&amp;nbsp; I've confirmed that I checked that box now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output from running 'cc -V -g -o my_pgm my_pgm.c':&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;cpp.ansi: HP92453-01 B.11.11.18 HP C Preprocessor (ANSI)
ccom: HP92453-01 B.11.11.18 HP C Compiler
cc: "my_pgm.c", line 431: warning 527: Integral value implicitly converted to pointer in assignment.
/usr/ccs/bin/ld: 92453-07 linker linker ld B.11.70 100609&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On the typo, I'm not sure how that happened.&amp;nbsp; I clicked on the Insert code sample, but I must have inadvertently added that extra 'n' character.&amp;nbsp; Given that there is no 'getnenv' function anywhere in my program, there definitely would have been an error at link time.&amp;nbsp; I have confirmed that the code I am compiling is using the correct spelling:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;    my_path_envvar = (char*)getenv("PATH");
    printf("Current PATH is %s\n", my_path_envvar);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 19:26:17 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058232#M491262</guid>
      <dc:creator>savage54</dc:creator>
      <dc:date>2019-08-09T19:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: strangeness with getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058236#M491263</link>
      <description>&lt;P&gt;&amp;gt; [...] I've confirmed that I checked that box now.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Some other-company Lithium forums are configured to pre-check that&lt;BR /&gt;box, but not these HPE ones, it seems.&amp;nbsp; Complain here:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;A href="https://community.hpe.com/t5/x/bd-p/community-feedback-suggestions" target="_blank"&gt;https://community.hpe.com/t5/x/bd-p/community-feedback-suggestions&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;gt; [...] I have confirmed that the code I am compiling is using the&lt;BR /&gt;&amp;gt; correct spelling: [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Ok.&lt;/P&gt;&lt;P&gt;&amp;gt; The man page for getenv() states [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I'd bet that it also mentions "#include &amp;lt;stdlib.h&amp;gt;".&amp;nbsp; If you omit&lt;BR /&gt;that, then you won't have a proper declaration of getenv(), and you'll&lt;BR /&gt;get the implicit type "int".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; I don't have a real-money HP[E] C compiler, only an old GCC (and on&lt;BR /&gt;IA64, too), but around here, without the &amp;lt;stdlib.h&amp;gt;, I get a similar&lt;BR /&gt;complaint:&lt;/P&gt;&lt;P&gt;dyi $ gcc -c getnenv.c&lt;BR /&gt;getnenv.c: In function 'my_test_function':&lt;BR /&gt;getnenv.c:8: warning: assignment makes pointer from integer without a cast&lt;BR /&gt;dyi $&lt;/P&gt;&lt;P&gt;_With_ "#include &amp;lt;stdlib.h&amp;gt;", all is quiet:&lt;/P&gt;&lt;P&gt;dyi $ gcc -c getnenv_d.c&lt;BR /&gt;dyi $&lt;/P&gt;&lt;P&gt;dyi $ diff getnenv.c getnenv_d.c&lt;BR /&gt;1a2&lt;BR /&gt;&amp;gt; #include &amp;lt;stdlib.h&amp;gt;&lt;BR /&gt;dyi $&lt;/P&gt;&lt;P&gt;dyi $ gcc -v&lt;BR /&gt;Using built-in specs.&lt;BR /&gt;Target: ia64-hp-hpux11.31&lt;BR /&gt;Configured with: ../gcc-4.3.3/configure&lt;BR /&gt;Thread model: posix&lt;BR /&gt;gcc version 4.3.3 (GCC)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; On a VMS system, you get more help (by default):&lt;/P&gt;&lt;P&gt;its $ cc getnenv&lt;/P&gt;&lt;P&gt;my_path_var = getenv("PATH");&lt;BR /&gt;.................^&lt;BR /&gt;%CC-I-IMPLICITFUNC, In this statement, the identifier "getenv" is implicitly dec&lt;BR /&gt;lared as a function.&lt;BR /&gt;at line number 8 in file ITS$DKA0:[SMS.itrc]getnenv.c;2&lt;/P&gt;&lt;P&gt;my_path_var = getenv("PATH");&lt;BR /&gt;...^&lt;/P&gt;&lt;P&gt;%CC-W-CVTDIFTYPES, In this statement, "getenv(...)" of type "int", is being conv&lt;BR /&gt;erted to "pointer to char".&lt;BR /&gt;at line number 8 in file ITS$DKA0:[SMS.itrc]getnenv.c;2&lt;BR /&gt;its $&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Or, on a Mac:&lt;/P&gt;&lt;P&gt;pro3$ cc -c getnenv.c&lt;BR /&gt;getnenv.c:8:18: warning: implicit declaration of function 'getenv' is invalid in&lt;BR /&gt;C99 [-Wimplicit-function-declaration]&lt;BR /&gt;my_path_var = getenv("PATH");&lt;BR /&gt;^&lt;BR /&gt;getnenv.c:8:16: warning: incompatible integer to pointer conversion assigning to&lt;BR /&gt;'char *' from 'int' [-Wint-conversion]&lt;BR /&gt;my_path_var = getenv("PATH");&lt;BR /&gt;^ ~~~~~~~~~~~~~~&lt;BR /&gt;2 warnings generated.&lt;BR /&gt;pro3$&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Of course, with "#include &amp;lt;stdlib.h&amp;gt;", everyone's happy:&lt;/P&gt;&lt;P&gt;its $ cc getnenv_d&lt;BR /&gt;its $&lt;/P&gt;&lt;P&gt;its $ cc /version&lt;BR /&gt;HP C V7.3-020 on OpenVMS IA64 V8.4&lt;/P&gt;&lt;P&gt;pro3$ cc -c getnenv_d.c&lt;BR /&gt;pro3$&lt;/P&gt;&lt;P&gt;pro3$ cc -v&lt;BR /&gt;Apple LLVM version 8.0.0 (clang-800.0.42.1)&lt;BR /&gt;Target: x86_64-apple-darwin15.6.0&lt;BR /&gt;Thread model: posix&lt;BR /&gt;InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/&lt;BR /&gt;XcodeDefault.xctoolchain/usr/bin&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; One of the problems with trying to debug a code fragment, is that&lt;BR /&gt;it's a code fragment, not an actual test case.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 20:34:50 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058236#M491263</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2019-08-09T20:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: strangeness with getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058239#M491264</link>
      <description>&lt;P&gt;That was it!&amp;nbsp; I had omitted &amp;lt;stdlib.h&amp;gt; from the list of #includes.&amp;nbsp; I had 12 other #includes, but I missed that one.&amp;nbsp; After adding that, and removing the explicit cast, it compiles with no warnings.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for spotting that oversight.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 21:25:12 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058239#M491264</guid>
      <dc:creator>savage54</dc:creator>
      <dc:date>2019-08-09T21:25:12Z</dc:date>
    </item>
    <item>
      <title>Re: strangeness with getenv()</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058240#M491265</link>
      <description>&lt;P&gt;&amp;gt; That was it! [...]0&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Thanks for the report.&amp;nbsp; (What could go wrong?)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; If I were relying on a compiler which didn't have, by default, a&lt;BR /&gt;specific warning for implicit function declarations, then I'd be looking&lt;BR /&gt;for an option to enable one.&amp;nbsp; (Or for a better compiler.)&amp;nbsp; You might get&lt;BR /&gt;by (silently) for an integer-returning function, but you still won't get&lt;BR /&gt;the argument type-checking which an actual function prototype provides.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Relying on yourself never to omit a required header file is a&lt;BR /&gt;technique which has been demonstrated to be inadequate.&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 21:54:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/strangeness-with-getenv/m-p/7058240#M491265</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2019-08-09T21:54:06Z</dc:date>
    </item>
  </channel>
</rss>

