Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9216565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:26:41+00:00 2026-06-18T02:26:41+00:00

I am recently saw some code, I am especially not clear of similar function

  • 0

I am recently saw some code, I am especially not clear of similar function pointer?

and below are function pointer.

I also is confused about below three function, the parameter type is “cairo_output_stream_t”, but the cairo_output_stream_t structure contain member of there three function pointer. I can not understand what below function are doing.

typedef cairo_status_t
(*cairo_output_stream_write_func_t) (cairo_output_stream_t *output_stream,
                                     const unsigned char   *data,
                                     unsigned int           length);

typedef cairo_status_t
(*cairo_output_stream_flush_func_t) (cairo_output_stream_t *output_stream);

typedef cairo_status_t
(*cairo_output_stream_close_func_t) (cairo_output_stream_t *output_stream);

struct _cairo_output_stream {
    cairo_output_stream_write_func_t write_func;
    cairo_output_stream_flush_func_t flush_func;
    cairo_output_stream_close_func_t close_func;
    unsigned long                    position;
    cairo_status_t                   status;
    int                              closed;
};

cairo_status_t is an enum

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T02:26:42+00:00Added an answer on June 18, 2026 at 2:26 am

    What’s basically being done is a C-like way to emulate C++’s this pointer … you pass a pointer to the struct as the first argument to the function call, and from that pointer you can call “methods” of the struct (in this case they are function pointers) and/or access data-members of the struct.

    So for instance, you might have code using this style of programming that looks something like the following:

    struct my_struct
    {
        unsigned char* data;
        void (*method_func)(struct my_struct* this_pointer);
    };
    
    struct my_struct object;
    //... initialize the members of the structure
    
    //make a call using one of the function pointers in the structure, and pass the 
    //address of the structure as an argument to the function so that the function
    //can access the data-members and function pointers in the struct
    object.method_func(&object);
    

    Now method_func can access the data member of the my_struct instance in the same way a C++ class method can access its class-instance non-static data-members through the this pointer.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently saw some Perl code that confused me. I took out all of
I recently saw someone with a T-shirt with some Perl code on the back.
I recently saw some Clojure or Scala (sorry I'm not familiar with them) and
I recently saw some code that reminded me to ask this question. Lately, I've
I recently saw some code from a college teacher where he had something like
Was recently reviewing some Java Swing code and saw this: byte[] fooReference; String getFoo()
I recently saw something in some code that made me curious if it was
I recently saw something interesting in some c++ code: try { //doStuff } catch
Recently I saw some code like this: <tr> <th> Some label: </th> <td> <input
In some code I saw recently there was a structure defined like this: typedef

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.