Pointer to integer without a cast

This is a discussion on Pointer to integer without a cast within the C Programming forums, part of the General Programming Boards category; I'm trying to a get a pointer to my raster pixel data here, in cairo. But the problem is more ...

  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
    21,456
    What is the return type and signature of cairo_surface_map_to_image? What is the type of surface?
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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
    21,456
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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,831
    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
    21,456
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    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, 01: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, 02:14 PM
  4. Help: makes pointer from integer without a cast
    By steffi in forum C Programming
    Replies: 4
    Last Post: 11-14-2007, 03:38 AM
  5. Pointer from integer without cast
    By STDSkillz in forum C Programming
    Replies: 2
    Last Post: 10-22-2007, 09:39 PM

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