Thread: Pointer to integer without a cast

  1. #1
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153

    Pointer to integer without a cast

    I'm trying to a get a pointer to my raster pixel data here, in cairo. But the problem is more of a broader c one. I hope Laser is around, she'll know this one. The second line of code is throwing a 'initialization makes pointer from integer without a cast'
    Code:
    cairo_rectangle_int_t *rect = &(cairo_rectangle_int_t){100, 100, 1, 1}; // COMPILES FINE
    cairo_surface_t *image=cairo_surface_map_to_image(surface , rect); // THIS BARFS
    I tried passing &rect into the initializer, that didn't work. Any ideas. Thanks. - Javaeyes

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    What is the return type and signature of cairo_surface_map_to_image? What is the type of surface?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    If I could find the API I'd be in a lot better shape, but I cannot find the API, I think it's so new that the devs may not have released it. I am posting also on the #cairo IRC channel and the devs do their best to answer me, but they are very busy, as are you. The type of surface is: cairo_surface_t *surface. So it's a pointer to a cairo_surface_t, which I am pretty sure is what the function initializer expects. I am assuming it returns another surface. Basically I'm passing in a surface, and then coordinates for a rectangle within that surface and returning a smaller surface -- which will then give me access to the raw raster pixel data. I'll keep searching for the API but when I google the function name only a couple pages show up and it is mostly devs discussing how the API should work.

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by javaeyes
    If I could find the API I'd be in a lot better shape, but I cannot find the API, I think it's so new that the devs may not have released it.
    Unfortunately, that's the crux of the problem. If you don't know what arguments the function expects, then it is hard to know how to call it correctly. If you don't know what the function returns, then it is hard to use its return value correctly. However, at the very least my question can be answered by looking up the header in which cairo_surface_map_to_image is declared.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    Ahhhhhhhhhhhhh! Let me parse through the headers. Thanks Laser! I also directly asked the devs if there is an API somewhere where google hasn't indexed yet.

  6. #6
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    Hmm. Cairo has only 1 included header. I searched for the function name and nothing came up. The header also includes three other headers, and I searched them, but there's nothing there. Now I'm officially at a temporary dead end. Can you see any trails to follow Laser?

  7. #7
    Registered User
    Join Date
    Sep 2008
    Location
    Toronto, Canada
    Posts
    1,834
    Did you include cairo.h ?

  8. #8
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    Yes I included cairo.h, also searched for the string literal "cairo_surface_map_to_image" within cairo.h, nothing shows up. I also parsed the file manually, by eye, and I cannot find it. Maybe it's just not there?

  9. #9
    Registered User javaeyes's Avatar
    Join Date
    Feb 2012
    Posts
    153
    If a function isn't in a header file, you aren't going to be able to use it are you?

  10. #10
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by javaeyes
    If a function isn't in a header file, you aren't going to be able to use it are you?
    Yes, though you could forward declare the function yourself if you know what is the correct declaration, which you don't in this case.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. pointer from integer without a cast - warning
    By Andreea Coman in forum C Programming
    Replies: 17
    Last Post: 01-11-2012, 02:48 PM
  2. 'Makes pointer from integer without a cast'
    By idlackage in forum C Programming
    Replies: 5
    Last Post: 06-10-2010, 05:48 AM
  3. integer to pointer without cast
    By eidgeare in forum C Programming
    Replies: 3
    Last Post: 12-08-2009, 03:14 PM
  4. Help: makes pointer from integer without a cast
    By steffi in forum C Programming
    Replies: 4
    Last Post: 11-14-2007, 04:38 AM
  5. Pointer from integer without cast
    By STDSkillz in forum C Programming
    Replies: 2
    Last Post: 10-22-2007, 09:39 PM