From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,73bf5f40f1c03632,start X-Google-Attributes: gidfee84,public From: Jason Mancini Subject: Re: dunix/cxx/mknod Date: 1998/08/25 Message-ID: <35E3030E.AD01EF5A@pa.dec.com>#1/1 X-Deja-AN: 384637784 Content-Transfer-Encoding: 7bit References: <35E2007A.A7767FA1@pa.dec.com> <35E27DA1.A926226E@zko.dec.com> Content-Type: text/plain; charset=us-ascii Organization: Terrific Mime-Version: 1.0 Newsgroups: comp.unix.osf.osf1 Dave Butenhof wrote: > > Jason Mancini wrote: > > > Accoring to the man page (2), mknod is in libc.a, > > and defined in . However, I can't > > seem to get my program to compile without an > > explicit prototype, and if I do provide the mknod > > prototype, it won't link. Is there a special > > -l switch needed? > > > > Trying to use mknod to create interprocess pipes. > > > > In stat.h: > > > > #ifdef _XOPEN_SOURCE_EXTENDED > > extern int mknod __((const char *, mode_t, dev_t )); > > #endif > > > > Why the _XOPEN_SOURCE_EXTENDED... > First, this question really isn't appropriate for > comp.programming.threads. This newsgroup deals with MULTITHREADED > programming issues. Since you're apparently concerned with Digital UNIX, > and interested in using news as a programming resource, you should be > reading the comp.unix.osf.osf1 newsgroup -- which specifically deals > with Digital UNIX. The program consists of multiple threads and multiple processes, sorry for the confusion. I have seen much more useless posts, I thought there might be a quick answer for a quick question. I monitor the ng mentioned, don't see many programming Q's there. But I'll give it a try... Back to the issue. > In this case, though, there is no magic involved, so I can't imagine why > you'd have trouble linking with an "appropriate" prototype of your own. > Since you didn't show the code or your compile/link command, there's no > way to guess what you may have done wrong. Because the cc and cxx > commands (if you allow them to link) will always link against libc, and > that's where mknod() lives, there should be no problem. If you're using > ld rather than cc or cxx to link, then there are several additional > things you need to worry about, which I won't detail here except to say > that "-lc" is only one of them. I tried every library that is installed on my machine that I could find, hence my confusion. "-lc" was attempted. > As for _XOPEN_SOURCE_EXTENDED... despite the inaccurate "standards" text > in the man page, mknod() is NOT a POSIX.1 function. It was, in fact, > deliberately excluded from that standard. (Instead, you should use > either mkfifo() or mkdir().) The Single UNIX Specification, however, > (XPG4, or UNIX95) includes mknod(), and requires that the prototype be > in . That's fine, except that, because the function is NOT > specified by POSIX.1, the name must not intrude on the user's (your) > namespace when compiling POSIX conforming code. If you want it, you must > explicitly request the UNIX95 namespace when you compile. > (Finally, and parenthetically, if you want to follow up on this please > do so by posting to comp.unix.osf.osf1, or, since you're at .dec.com, to > the Digital UNIX notes conference, rather than replying here.) Thanks for the lead! > > /---------------------------[ Dave Butenhof ]--------------------------\ > | Compaq Computer Corporation butenhof@zko.dec.com | > | 110 Spit Brook Rd ZKO2-3/Q18 http://members.aol.com/drbutenhof | > | Nashua NH 03062-2698 http://www.awl.com/cseng/titles/0-201-63392-2/ | > \-----------------[ Better Living Through Concurrency ]----------------/ Let me try again. blah.cpp/blah.c: #include void main() {mknod("foo", S_IFIFO | 0666, 0);} > cxx blah.cpp cxx: Error: blah.cpp, line 7: In this statement, "mknod" is not declared. mknod("foo", S_IFIFO | 0666, 0); --^ > cc blah.c > (works) > c89 blah.c > (works) blah.cpp/blah.c: #include int mknod(const char *path, int mode, dev_t device); void main() {mknod("foo", S_IFIFO | 0666, 0);} > cxx blah.cpp ld: Unresolved: mknod(const char*, int, int) > cc blah.c > (works) > c89 blah.c cc: Warning: blah.c, line 3: In this declaration, parameter 2 has a different type than specified in an earlier declaration of this function. ... ... So what gives with cxx? (Same thing happens with usleep.) Thanks /Jason