Quick help needed please

This is a discussion on Quick help needed please within the C Programming forums, part of the General Programming Boards category; Hi all, I'm stuck with this program and cannot figure out why it's not compiling on me. It keeps giving ...

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    14

    Quick easy help needed please

    Hi all, I'm stuck with this program and cannot figure out why it's not compiling on me. It keeps giving me an 'undefined reference to bar' error message and fails to compile. Any ideas/suggestions please? Thanks

    Code:
    #include <stdio.h>
    
    extern void bar(int *);
    
    void progy ()
    {
             int *val;
      
             bar(val);
            
             .....
    
             .....
    
    }
    
    main() 
    {
    
    progy();
    
    ....
    
    ....
    
    
    }
    Last edited by ninjacookies; 03-01-2005 at 11:34 AM.

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,798
    Fails to compile or fails to link? Do you have a bar function defined in some other source file somewhere? If you don't then I'd expect it to compile but not link.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,484
    > It keeps giving me an 'undefined reference to bar' error message and fails to compile.
    You've stated with "extern void bar(int *);" that bar is in another file.

    Depending on your compiler / IDE, you need to arrange for the following to happen
    gcc prog.c bar.c
    That is, you need to compile ALL your source files.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Quick help needed on simple example
    By hiven in forum C Programming
    Replies: 6
    Last Post: 05-13-2009, 12:46 AM
  2. will this work? just a quick test needed
    By shoobsie in forum C Programming
    Replies: 22
    Last Post: 07-11-2005, 11:31 AM
  3. Quick help needed....!!
    By AssistMe in forum C Programming
    Replies: 1
    Last Post: 02-25-2005, 04:44 AM
  4. error with function, help needed quick
    By chris285 in forum C++ Programming
    Replies: 3
    Last Post: 04-30-2003, 08:31 AM
  5. "break" - quick response needed
    By luke in forum C Programming
    Replies: 4
    Last Post: 04-23-2002, 08:57 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21