[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: C++ question



Noah L. Meyerhans [frodo@morgul.net] wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> 
> On Tue, 15 Feb 2000, Shao Zhang wrote:
> 
> > Eg. if I compile with this:
> > $ g++ -g -c misc.c
> > misc.c: In function `char * cash(double, int, int)':
> > misc.c:44: implicit declaration of function `int bracket(...)'
> > misc.c:45: implicit declaration of function `int comma(...)'
> > 
> > 
> > The output is exactly the same with the newest g++ version, and older
> > g++. But the difference is that the older version will create a .o file
> > and the new version will not. And I can only see an error message when
> > they are compiled using make.
> 
> Could you please post the relevant lines from your source?  It was not
> included with your first post.  Are 'bracket' and 'comma' functions that
> you have defined, or are they variables?

Those two functions were declared in a another C file. And that C file
is compiled with gcc. As soon as I found that, adding an extern "C" in
the header file fixed the problem.

So it is clear that the new version of g++ is much more restrictive, but
I still prefer it will give me a clear error message so that I know
there is something wrong...

> Also, why are you using g++?  All this looks like C code, and your source
> file ends in a lowercase 'c'.  The C++ compiler should handle it properly,
> of course, but I've seen (and can post, if you want) some examples of
> valid C code that won't compile in a C++ compiler.  I don't know how
> g++/gcc handle situations like this, but it seems a bit suspicious to me.

The code was originally written by someone else, and I had to modify it.
It uses a whole bunch of libraries written in C. And I am too lazy to
port it to C++. So I had to use both gcc and g++. But it is just a pain
to keep the memory allocation consistent(new/delete, malloc/free).

-- 
____________________________________________________________________________
Shao Zhang - Running Debian 2.1  ___ _               _____
Department of Communications    / __| |_  __ _ ___  |_  / |_  __ _ _ _  __ _ 
University of New South Wales   \__ \ ' \/ _` / _ \  / /| ' \/ _` | ' \/ _` |
Sydney, Australia               |___/_||_\__,_\___/ /___|_||_\__,_|_||_\__, |
Email: shao@cia.com.au                                                  |___/ 
_____________________________________________________________________________


Reply to: