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

  • SEARCH
  • Home
  • 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 8164717
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:22:44+00:00 2026-06-06T19:22:44+00:00

I am using curl library which returns data to me through a callback function

  • 0

I am using curl library which returns data to me through a callback function with the prototype below

size_t write_data(void * data, size_t size, size_t nmemb, void * userpointer);

I noticed that if i declare a function fitting this prototype in my class

//file Dialog.h
class Dialog : public QDialog
{
    private:
    int new_data_callback(void * newdata, size_t size, size_t nmemb, QByteArray * buffer); 
}

If i try to use it in my Dialog.cpp

curl_easy_setopt(curl_handle,CURLOPT_WRITEFUNCTIION, new_data_callback);

I get an error

Invaid use of member (did you forget the '&'?)

If i add static to my function declaration, it compiles.

static int new_data_callback(void * newdata, size_t size, size_t nmemb, QByteArray * buffer); //ok

Question

Why is static needed in this case?

PS: the classes beginning with Q eg QDialog are part of QT and dont affect the question.

  • 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-06T19:22:44+00:00Added an answer on June 6, 2026 at 7:22 pm

    Because a non-static method cannot be called without an instance. Since new_data_callback is a callback, the only way to attach an instance to it is through a parameter. Making it static removes the instance restriction.

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

Sidebar

Related Questions

I have an R function which calls a webserver database through it's API using
I am indexing the file using php curl library. I am stuck here with
I using curl to post data to another server, between each posting I use
I'm using the Codeigniter Curl library, and the author uses the integer equivalents of
I'm trying to download a test file from my server using the cURL library
Having issues using cURL on windows vista. The library is there and showing with
I have some PHP code that calls into the cURL library. I'm using it
I've made a twitter bot using the CURL library for PHP, and a MySQL
when using cURL in php to send data in a POST, you use set
I have some code that is using the PHP cURL library to upload some

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.