Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Re: help with old source code from book

Reply
Thread Tools

Re: help with old source code from book

 
 
Mug
Guest
Posts: n/a
 
      08-01-2009
On Aug 1, 12:56*am, superpollo <(E-Mail Removed)> wrote:
> Richard Heathfield wrote:
> > superpollo said:

>
> > <snip>

>
> >>and if i delete the offending #include <alloc.h> from the two files,
> >>i get:

>
> >>$ gcc LIST2_1.C iplib.c
> >>LIST2_1.C: In function `int main(int, char**)':
> >>LIST2_1.C:53: warning: converting to `int' from `double'

>
> > Should be easy enough to determine whether or not that conversion is
> > appropriate.

>
> >>LIST2_1.C:71: error: `free' undeclared (first use this function)

>
> > Well, that's easily fixed. Just add the appropriate header. For
> > free(), that's <stdlib.h>

>
> i added the #include <stdlib.h> to LIST2_1.C, and:
>
> $ gcc LIST2_1.C iplib.c
> LIST2_1.C: In function `int main(int, char**)':
> LIST2_1.C:54: warning: converting to `int' from `double'
> /tmp/ccIpyCSo.o(.text+0x5f): In function `main':
> : warning: the `gets' function is dangerous and should not be used.
> /tmp/ccIpyCSo.o(.text+0xae): In function `main':
> : undefined reference to `read_pnm(char*, int*, int*, int*)'
> /tmp/ccIpyCSo.o(.text+0x21c): In function `main':
> : undefined reference to `write_pnm(unsigned char*, char*, int, int, int)'
> /tmp/ccIpyCSo.o(.eh_frame+0x11): undefined reference to
> `__gxx_personality_v0'
> collect2: ld returned 1 exit status
> $


i have the same result,yet those functions are declared in iplib.c
 
Reply With Quote
 
 
 
 
Mug
Guest
Posts: n/a
 
      08-01-2009
On Aug 1, 1:29*am, Beej Jorgensen <(E-Mail Removed)> wrote:
> Mug *<(E-Mail Removed)> wrote:
> >i have the same result,yet those functions are declared in iplib.c

>
> Funky. *I'd help out, but it compiles for me. :-/ *With the
> alloc.h/stdlib.h fixes:
>
> $ gcc -Wall list2_1.c iplib.c
> iplib.c: In function 'getnum':
> iplib.c:156: warning: suggest explicit braces to avoid ambiguous 'else'
> /tmp/ccQIltLY.o: In function `main':
> list2_1.c.text+0x7e): warning: the `gets' function is dangerous and
> should not be used.
>

i got the same result,after changing LIST2_1.C to LIST2_1.c
strange

> $ gcc --version
> gcc (GCC) 4.3.3
>
> Compiles in C99 mode, too.
>
> Maybe try:
>
> gcc -c LIST2_1.C
> gcc -c iplib.c
> gcc LIST2_1.o iplib.o
>
> not that it should make any difference.
>
> -Beej

 
Reply With Quote
 
 
 
 
Beej Jorgensen
Guest
Posts: n/a
 
      08-01-2009
Mug <(E-Mail Removed)> wrote:
>i have the same result,yet those functions are declared in iplib.c


Funky. I'd help out, but it compiles for me. :-/ With the
alloc.h/stdlib.h fixes:

$ gcc -Wall list2_1.c iplib.c
iplib.c: In function 'getnum':
iplib.c:156: warning: suggest explicit braces to avoid ambiguous 'else'
/tmp/ccQIltLY.o: In function `main':
list2_1.c.text+0x7e): warning: the `gets' function is dangerous and
should not be used.

$ gcc --version
gcc (GCC) 4.3.3

Compiles in C99 mode, too.

Maybe try:

gcc -c LIST2_1.C
gcc -c iplib.c
gcc LIST2_1.o iplib.o

not that it should make any difference.

-Beej

 
Reply With Quote
 
Beej Jorgensen
Guest
Posts: n/a
 
      08-01-2009
Gordon Burditt <(E-Mail Removed)> wrote:
>*DECLARE* them all you want; but when you go to link the program
>these functions have to be *DEFINED* somewhere.


Terminology confusion on the part of the parent--the functions really
are defined right there in iplib.c. I linked to them without a problem.

-Beej

 
Reply With Quote
 
Beej Jorgensen
Guest
Posts: n/a
 
      08-01-2009
Mug <(E-Mail Removed)> wrote:
>i got the same result,after changing LIST2_1.C to LIST2_1.c
>strange


Oh, blast from the past! Wasn't .C the old extension for C++ files?
Maybe a name mangling issue, and probably explains the gxx_personality
linker error.

-Beej

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
13 year old C source code buck C Programming 14 08-03-2011 08:17 AM
Re: [LONG] help with old source code from book Phil Carmody C Programming 2 08-03-2009 09:58 PM
Re: help with old source code from book Mug C Programming 2 08-01-2009 04:39 PM
old repository for old C++ source code *Prot3anThr3ad* C++ 6 10-02-2006 04:44 AM
old repository for old C++ source code *Prot3anThr3ad* Computer Support 7 10-02-2006 04:44 AM



Advertisments