- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- undeclared constants when compiling with gcc -std=...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2016 08:42 PM - edited 05-10-2016 08:42 PM
05-10-2016 08:42 PM - edited 05-10-2016 08:42 PM
Hello,
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.
Here is a simple example to reproduce the issue:
#include <errno.h> #include <stdio.h> #include <stdlib.h> int main() { if (EINVAL == 22) { printf("Invalid argument\n"); } else { printf("unknown EINVAL\n"); } return 0; }
Works fine if I compile this program without '-std=c99'.
$ gcc test.c -o test
$ ./test
Invalid argument
Now if I compile it with -std=c99:
$ gcc -std=c99 test.c -o test:
test.c: In function 'main':
test.c:6: error: 'EINVAL' undeclared (first use in this function)
test.c:6: error: (Each undeclared identifier is reported only once
test.c:6: error: for each function it appears in.)
Any idea why I get such error with c99?
Thank you in advance for your help.
Maxime
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-10-2016 10:20 PM
05-10-2016 10:20 PM
Solution> I use gcc to compile on HP-UX ia V2.
Actual output from, say:
uname -a
gcc -v
would be more helpful than your vague descriptions. Around here:
dyi# uname -a
HP-UX dyi B.11.31 U ia64 4235313755 unlimited-user license
dyi# gcc -v
Using built-in specs.
Target: ia64-hp-hpux11.31
Configured with: ../gcc-4.3.3/configure
Thread model: posix
gcc version 4.3.3 (GCC)
I know approximately nothing about c99 or what "-std=c99" does to
GCC, but a quick look at /usr/include/sys/errno.h (pulled in by
/usr/include/errno.h) suggests that defining _INCLUDE_POSIX_SOURCE might
be useful:
dyi# gcc -o test_c99 test_c99.c
dyi#
dyi# gcc -o test_c99_c99 -std=c99 test_c99.c
test_c99.c: In function 'main':
test_c99.c:6: error: 'EINVAL' undeclared (first use in this function)
test_c99.c:6: error: (Each undeclared identifier is reported only once
test_c99.c:6: error: for each function it appears in.)
dyi#
dyi# gcc -o test_c99_c99 -std=c99 test_c99.c -D_INCLUDE_POSIX_SOURCE
dyi#
If you have some good reason to specify "-std=c99", then it might
pay first to learn what it does.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-12-2016 01:55 AM
05-12-2016 01:55 AM
Re: undeclared constants when compiling with gcc -std=c99
Thank you.
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.)
I found out that using the standard 'gnu99' solves all these issues.
From the man page of gcc:
gnu99 is ISO C99 plus GNU extensions.