Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Jason Mancini <jmancini@pa.dec.com>
Subject: Re: dunix/cxx/mknod
Date: 1998/08/25	[thread overview]
Message-ID: <35E3030E.AD01EF5A@pa.dec.com> (raw)
In-Reply-To: 35E27DA1.A926226E@zko.dec.com

Dave Butenhof wrote:
> 
> Jason Mancini wrote:
> 
> > Accoring to the man page (2), mknod is in libc.a,
> > and defined in <sys/stat.h>.  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<library> 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.

<snip>

> 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 <sys/stat.h>. 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.

<snip>

> (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 <sys/stat.h>
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 <sys/stat.h>
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



       reply	other threads:[~1998-08-25  4:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <35E2007A.A7767FA1@pa.dec.com>
     [not found] ` <35E27DA1.A926226E@zko.dec.com>
1998-08-25  4:00   ` Jason Mancini [this message]
1998-08-25  4:00     ` dunix/cxx/mknod Stefan Schwarzer
1998-08-25  4:00       ` dunix/cxx/mknod Jason Mancini
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox