Nios® V/II Embedded Design Suite (EDS)
Support for Embedded Development Tools, Processors (SoCs and Nios® V/II processor), Embedded Development Suites (EDSs), Boot and Configuration, Operating Systems, C and C++
12622 Discussions

Using open and other HAL unix standard functions

Altera_Forum
Honored Contributor II
1,560 Views

How do I use them? The HAL manual says to include <unistd.h> but this doesn&#39;t work. The example code says to include <stdio.h> but never mentions unistd.h. Neither of these work for me. I can&#39;t find where the alt_open.c declartion is declared in any header. 

 

Why is the documentation so wrong? How do I use open.
0 Kudos
4 Replies
Altera_Forum
Honored Contributor II
399 Views

OK the prototypes for the alt_open.c file are in alt_sys_wrappers.h 

 

But I have searched my entire harddrive for the flag definitions and found nothing (O_RDWR, WR_ONLY etc.). Also the example code uses open like you would fopen (with only 2 parameters).
0 Kudos
Altera_Forum
Honored Contributor II
399 Views

It seems my installation was corrupted and I was missing some library files. A reinstall seems to have fixed everything. 

 

However it does still appear to need <fctrl.h> included, even though the documentation doesn&#39;t specify this.
0 Kudos
Altera_Forum
Honored Contributor II
399 Views

Whenever I come upon a question of what headers to include, I hop onto a computer with a "real" OS (i.e.: *not* Windows!) and view the manpage of the function in question. In this case the top part of the manpage for "open", returns: 

 

SYNOPSIS      # include <sys/types.h>      # include <sys/stat.h>      # include <fcntl.h>       int open(const char *pathname, int flags);       int open(const char *pathname, int flags, mode_t mode);       int creat(const char *pathname, mode_t mode); 

 

This tends to save me time and, since Windows documentation is a complete mess, it&#39;s much easier to find things on UNIX (or UNIX-like) OSs. If the documentation is wrong, it should certainly be updated, but I believe this little bit of info. to "common" knowledge... The two manpages I looked at (on Linux and Solaris) both had identical information. 

 

Cheers, 

 

- slacker
0 Kudos
Altera_Forum
Honored Contributor II
399 Views

Also another resource I&#39;ve found: just google the function name... I usually wind up at a site such as http://www.cplusplus.com/ref/indexr.html (http://www.cplusplus.com/ref/indexr.html) which tells me all sorts of useful things about the routine I&#39;m interested in, including header files, in a pretty non-man-page format.

0 Kudos
Reply