🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.help
Article #841

Re: Problems #including K&R function prototypes from C++

#841
From: Max Welton
Date: Tue, 28 Nov 1995 00:11
44 lines
1695 bytes
shekar@gizmo.cs.msstate.edu (Shekar Ramanathan) wrote:
>Max Welton (maxw@lmsc.lockheed.com) wrote:
[snip]
>What you should do is have another file called foo.c and compile it using
>a K&R C compiler.  In main.C, you should just include a prototype declaration
>for foo and finally link them together.
>
>foo.c
>int foo(boo)
>    int boo;
>{
>   return boo;   
>}
>
>main.C:
>
>extern "C"{
>	int foo();
>}
>int main()
>{ cout << foo(0) << endl; }
>
>
>Shekar

I have the same problem with or without the 'extern"C"'. In the 
real-world case, "foo.h" is a 3rd-party vendor header. We're just 
not in a position to rewrite our favorite vendor's K&R headers.

I was hoping that g++ could be cajoled somehow into the behaviour 
of our HP cfront compiler in this case:

  CC -c main.C
  CC: "main.C", line 4: warning: old style definition of foo() (anachronism) 
  (1386)

  Compilation finished at Mon Nov 27 11:35:38

Not there yet...

--
Max Welton, CMST (Coordinator of Many Small Things)
   maxw@lmsc.lockheed.com
   maxw@ix.netcom.com
Technical Details
Message-ID: <49dk3d$s46@butch.lmsc.lockheed.com>
Path: arc1-ca.pugleaf.net!newsjunkie.ans.net!butch!news
References: <49d4ic$ooq@butch.lmsc.lockheed.com> <49da94$kev@NNTP.MsState.Edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!newsjunkie.ans.net!butch!news
From: Max Welton <maxw@lmsc.lockheed.com>
Newsgroups: gnu.g++.help,comp.lang.c++
Subject: Re: Problems #including K&R function prototypes from C++
Date: 28 Nov 1995 00:11:25 GMT
Organization: 42-10
Message-ID: <49dk3d$s46@butch.lmsc.lockheed.com>
References: <49d4ic$ooq@butch.lmsc.lockheed.com> <49da94$kev@NNTP.MsState.Edu>
NNTP-Posting-Host: bismark.ssd.lmsc.lockheed.com
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.05 9000/715)
X-URL: news:49da94$kev@NNTP.MsState.Edu