<?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 undeclared constants when compiling with gcc -std=c99 in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/undeclared-constants-when-compiling-with-gcc-std-c99/m-p/6858278#M494971</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I use gcc to compile on HP-UX ia V2. When I use '-std=c99', the compiler returns many undeclared constants errors (i.e. EILSEQ, EINVAL, E2BIG, etc.). If I remove this c99 option, then the program compiles fine.&lt;/P&gt;&lt;P&gt;Here is a simple example to reproduce the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

int main() {
    if (EINVAL == 22) {
        printf("Invalid argument\n");
    } else {
        printf("unknown EINVAL\n");
    }
    return 0;
}&lt;/PRE&gt;&lt;P&gt;Works fine if I compile this program without '-std=c99'.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;$ gcc test.c -o test&lt;BR /&gt;$ ./test&lt;BR /&gt;Invalid argument&lt;/P&gt;&lt;P&gt;Now if I compile it with -std=c99:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;$ gcc -std=c99 test.c -o test:&lt;BR /&gt;test.c: In function 'main':&lt;BR /&gt;test.c:6: &lt;STRONG&gt;error: 'EINVAL' undeclared (first use in this function)&lt;/STRONG&gt;&lt;BR /&gt;test.c:6: error: (Each undeclared identifier is reported only once&lt;BR /&gt;test.c:6: error: for each function it appears in.)&lt;/P&gt;&lt;P&gt;Any idea why I get such error with c99?&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;Maxime&lt;/P&gt;</description>
    <pubDate>Wed, 11 May 2016 03:42:59 GMT</pubDate>
    <dc:creator>maxime2</dc:creator>
    <dc:date>2016-05-11T03:42:59Z</dc:date>
    <item>
      <title>undeclared constants when compiling with gcc -std=c99</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/undeclared-constants-when-compiling-with-gcc-std-c99/m-p/6858278#M494971</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I use gcc to compile on HP-UX ia V2. When I use '-std=c99', the compiler returns many undeclared constants errors (i.e. EILSEQ, EINVAL, E2BIG, etc.). If I remove this c99 option, then the program compiles fine.&lt;/P&gt;&lt;P&gt;Here is a simple example to reproduce the issue:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;#include &amp;lt;errno.h&amp;gt;
#include &amp;lt;stdio.h&amp;gt;
#include &amp;lt;stdlib.h&amp;gt;

int main() {
    if (EINVAL == 22) {
        printf("Invalid argument\n");
    } else {
        printf("unknown EINVAL\n");
    }
    return 0;
}&lt;/PRE&gt;&lt;P&gt;Works fine if I compile this program without '-std=c99'.&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;$ gcc test.c -o test&lt;BR /&gt;$ ./test&lt;BR /&gt;Invalid argument&lt;/P&gt;&lt;P&gt;Now if I compile it with -std=c99:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;$ gcc -std=c99 test.c -o test:&lt;BR /&gt;test.c: In function 'main':&lt;BR /&gt;test.c:6: &lt;STRONG&gt;error: 'EINVAL' undeclared (first use in this function)&lt;/STRONG&gt;&lt;BR /&gt;test.c:6: error: (Each undeclared identifier is reported only once&lt;BR /&gt;test.c:6: error: for each function it appears in.)&lt;/P&gt;&lt;P&gt;Any idea why I get such error with c99?&lt;/P&gt;&lt;P&gt;Thank you in advance for your help.&lt;/P&gt;&lt;P&gt;Maxime&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 03:42:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/undeclared-constants-when-compiling-with-gcc-std-c99/m-p/6858278#M494971</guid>
      <dc:creator>maxime2</dc:creator>
      <dc:date>2016-05-11T03:42:59Z</dc:date>
    </item>
    <item>
      <title>Re: undeclared constants when compiling with gcc -std=c99</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/undeclared-constants-when-compiling-with-gcc-std-c99/m-p/6858288#M494972</link>
      <description>&lt;P&gt;&amp;gt; I use gcc to compile on HP-UX ia V2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Actual output from, say:&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; uname -a&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gcc -v&lt;BR /&gt;would be more helpful than your vague descriptions.&amp;nbsp; Around here:&lt;/P&gt;&lt;P&gt;dyi# uname -a&lt;BR /&gt;HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license&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; I know approximately nothing about c99 or what "-std=c99" does to&lt;BR /&gt;GCC, but a quick look at /usr/include/sys/errno.h (pulled in by&lt;BR /&gt;/usr/include/errno.h) suggests that defining _INCLUDE_POSIX_SOURCE might&lt;BR /&gt;be useful:&lt;BR /&gt;&lt;BR /&gt;dyi# gcc -o test_c99 test_c99.c&lt;BR /&gt;dyi#&lt;BR /&gt;dyi# gcc -o test_c99_c99 -std=c99 test_c99.c&lt;BR /&gt;test_c99.c: In function 'main':&lt;BR /&gt;test_c99.c:6: error: 'EINVAL' undeclared (first use in this function)&lt;BR /&gt;test_c99.c:6: error: (Each undeclared identifier is reported only once&lt;BR /&gt;test_c99.c:6: error: for each function it appears in.)&lt;BR /&gt;dyi#&lt;BR /&gt;dyi# gcc -o test_c99_c99 -std=c99 test_c99.c -D_INCLUDE_POSIX_SOURCE&lt;BR /&gt;dyi#&lt;BR /&gt;&lt;BR /&gt;&amp;nbsp;&amp;nbsp; If you have some good reason to specify "-std=c99", then it might&lt;BR /&gt;pay first to learn what it does.&lt;/P&gt;</description>
      <pubDate>Wed, 11 May 2016 05:20:52 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/undeclared-constants-when-compiling-with-gcc-std-c99/m-p/6858288#M494972</guid>
      <dc:creator>Steven Schweda</dc:creator>
      <dc:date>2016-05-11T05:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: undeclared constants when compiling with gcc -std=c99</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/undeclared-constants-when-compiling-with-gcc-std-c99/m-p/6858763#M494973</link>
      <description>&lt;P&gt;Thank you.&lt;/P&gt;&lt;P&gt;This indeed works for the constants inside errno.h. However, when I compiled my program I still got other undefined constants and functions (like CODESET, snprintf, etc.)&lt;/P&gt;&lt;P&gt;I found out that using the standard 'gnu99' solves all these issues.&lt;/P&gt;&lt;P&gt;From the man page of gcc:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;gnu99 is ISO C99 plus GNU extensions.&lt;/P&gt;&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Thu, 12 May 2016 08:55:23 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/undeclared-constants-when-compiling-with-gcc-std-c99/m-p/6858763#M494973</guid>
      <dc:creator>maxime2</dc:creator>
      <dc:date>2016-05-12T08:55:23Z</dc:date>
    </item>
  </channel>
</rss>

