Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Stefan Schwarzer <sts@boa.ica1.uni-stuttgart.de>
Subject: Re: dunix/cxx/mknod
Date: 1998/08/25	[thread overview]
Message-ID: <6rvbps$r30$1@infosun2.rus.uni-stuttgart.de> (raw)
In-Reply-To: 35E3030E.AD01EF5A@pa.dec.com

Jason Mancini <jmancini@pa.dec.com> wrote:
> Dave Butenhof wrote:
>> 

> 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: Warning: blah.c, line 3: In this declaration, parameter 2 has a
> different type than specified in an earlier declaration of this


You are hiding the c-library function by your repeated declaration of 
mknod before the main. At least you should use an extern "C" {} if you 
require such a hack for some reason. The c++ compiler will then not 
mangle the types into the function name and give the linker a chance to 
find the function name in the c-library... 
btw: the c compiler warns because the signature is not ok, the second argument is mode_t which is a typedef from unsigned int. 

The following works fine for me:

23:43 margay_sts:~> cat mknod.cc
#include <sys/stat.h>
int main(){
  mknod("foo", S_IFIFO |0666, 0);
}
23:43 margay_sts:~> cxx -D_XOPEN_SOURCE_EXTENDED mknod.cc
23:44 margay_sts:~> a.out
23:44 margay_sts:~> ls -l foo
prw-r--r--   1 sts      cron           0 Aug 25 23:44 foo|

-- 
Stefan Schwarzer                office:  +49-(0)711-685-7606   fax: x-3658 
70569 Stuttgart, Germany             http://www.ica1.uni-stuttgart.de/~sts



  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   ` dunix/cxx/mknod Jason Mancini
1998-08-25  4:00     ` Stefan Schwarzer [this message]
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