From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,73bf5f40f1c03632 X-Google-Attributes: gidfee84,public From: Stefan Schwarzer Subject: Re: dunix/cxx/mknod Date: 1998/08/25 Message-ID: <6rvbps$r30$1@infosun2.rus.uni-stuttgart.de>#1/1 X-Deja-AN: 384695847 References: <35E2007A.A7767FA1@pa.dec.com> <35E27DA1.A926226E@zko.dec.com> <35E3030E.AD01EF5A@pa.dec.com> Organization: ICA 1, Stuttgart University User-Agent: tin/pre-1.4-971224 (UNIX) (SunOS/5.5.1 (sun4u)) Newsgroups: comp.unix.osf.osf1 Jason Mancini wrote: > Dave Butenhof wrote: >> > 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: 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 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