Like Tree1Likes
  • 1 Post By Salem

Code example gives error:

This is a discussion on Code example gives error: within the C Programming forums, part of the General Programming Boards category; Bit Fields in C when I compile on my machine I have theerror: warning: format ‘%d’ expects argument of type ...

  1. #1
    Registered User
    Join Date
    Oct 2012
    Posts
    9

    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 wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,687
    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"
    nonpuz likes this.
    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.

  3. #3
    Registered User
    Join Date
    Nov 2012
    Posts
    1,209
    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, 07:09 AM
  2. error in code
    By zeybek258388 in forum C Programming
    Replies: 3
    Last Post: 12-31-2011, 02:34 PM
  3. bus error in code
    By 3MGFX in forum C Programming
    Replies: 4
    Last Post: 02-05-2009, 09:12 AM
  4. error with code
    By dayknight in forum C++ Programming
    Replies: 2
    Last Post: 01-21-2004, 01:43 PM
  5. i have an error in this code help?
    By ssjnamek in forum C++ Programming
    Replies: 12
    Last Post: 01-26-2002, 09:48 PM

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