Thread: Code example gives error:

  1. #1
    Registered User
    Join Date
    Oct 2012

    Code example gives error:

    Bit Fields in C
    when I compile on my machine I have theerror:
    warning: format ‘%d’ expects argument of type ‘int’,but argument 2 has type ‘long unsigned int’ [-Wformat]
    /usr/bin/ld: cannot find -lgmp
    /usr/bin/ld: cannot find -lreadline

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    I can't see why you would need either gmp or readline for that code.

    But to print a size_t in C99 code, you should use the format "%zd" in place of "%d"
    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.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Quote Originally Posted by eiger3970 View Post
    /usr/bin/ld: cannot find -lgmp
    /usr/bin/ld: cannot find -lreadline
    In gcc, it will bomb out if you specify a library that it cannot find, even if you don't need the library in your code. So if you don't need those libraries the solution is to remove '-lgmp -lreadline' from your compilation commandline.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Error in code
    By Waqas Asad in forum C Programming
    Replies: 4
    Last Post: 02-18-2012, 08:09 AM
  2. error in code
    By zeybek258388 in forum C Programming
    Replies: 3
    Last Post: 12-31-2011, 03:34 PM
  3. bus error in code
    By 3MGFX in forum C Programming
    Replies: 4
    Last Post: 02-05-2009, 10:12 AM
  4. error with code
    By dayknight in forum C++ Programming
    Replies: 2
    Last Post: 01-21-2004, 02:43 PM
  5. i have an error in this code help?
    By ssjnamek in forum C++ Programming
    Replies: 12
    Last Post: 01-26-2002, 10:48 PM