Thread: Another "Undefined Reference to..."

  1. #16
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    gcc -E linsock.c > linsock.i
    Then look at linsock.i in a text editor (it'll be very large).

    What you're looking at is what the compiler sees after the pre-processor has had it's turn.
    What you should look for is
    - whether the code for the function even exists - perhaps it was in a conditional block, or a comment
    - whether the function still has the same name, perhaps a macro substitution gone wrong.
    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.

  2. #17
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Well, I ran that and sure enough I could not find my function. I found the other two. All I found of lreceive was a declaration, but no function. I also searched for something similar but with a different name, but there wasn't any.

    If anyone wants to see the file, it is attached.

  3. #18
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    So I'm guessing it's in a big fat comment then?

    Put a single open comment /* or close comment */ inside the function, and see what sort of error messages you get out of it.

    Looking at your .i file is pointless, try the .c file.
    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.

  4. #19
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Ok. Strange update. I went to sleep and woke up, decided to give it another shot. I opened linsock.c, and the function was gone. I put it back in and now get the same warning tabstop did.

    I wonder what happened last night. I am using gedit. Could it possibly not have been saving it correctly?

    Code:
     warning: too few arguments for format
    Anyone know how to fix this. I can't find a clear cut definition from my google queries.
    Last edited by carrotcake1029; 01-29-2009 at 08:19 AM.

  5. #20
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    When you print a number with %d, you need to have a number to print.

  6. #21
    Registered User carrotcake1029's Avatar
    Join Date
    Apr 2008
    Posts
    404
    Haha, wow. Thank you.
    Thanks for your perseverance. I have no idea why I was having those issues. Last night I even tried closing and reopening gedit but I still had that same problem. It ended up that doing a restart caused me to realize that function was not being saved, for whatever reason it was.

  7. #22
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Most likely it was being saved elsewhere (subdirectory? parent directory? who knows?)

  8. #23
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,663
    Ah, the old "not compiling what you forgot to save", or "compiling the wrong copy" sketch.
    Seen it many times before, it's a classic.
    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.

  9. #24
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by Salem View Post
    Ah, the old "not compiling what you forgot to save", or "compiling the wrong copy" sketch.
    Seen it many times before, it's a classic.
    Yup, you haven't been a programmer for long if you haven't ever made that mistake. Of course, modern IDE's help a whole lot by not really bothering with where things are saved, autosaving, and such things.

    I've also been known to wonder why my code isn't printing my debug outputs and such things, only to figure out that I'm compiling for release-mode or that I've actually not copied the new code to the target system.... It's really embarrasing when it takes one of your colleagues to figure it out, when you should know better! A trick that I've used a few times is to put "sdjhasdk6&%$" somewhere in the code I'm editing, just to get an error - that way, I know I'm compiling the code I think I'm compiling [where I work now, we tend to have "drives" created with Windows/DOS subst that contain different projects - sometimes I've been working on the same bit of code in two different projects - it can get REALLY confusing at times].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  3. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  4. C OpenGL Compiler Error?
    By Matt3000 in forum C Programming
    Replies: 12
    Last Post: 07-07-2006, 04:42 PM
  5. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM