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 8419793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:42:40+00:00 2026-06-10T02:42:40+00:00

I am trying to pass some extra arguments so they can be used at

  • 0

I am trying to pass some extra arguments so they can be used at the SIGINT call on my program, but I am getting a compile error, is this actually achievable or am I misinformed?

If it is achievable, could someone please explain my mistake here;

void signal_handler(bool &txMode, char* &txData, int &sendresult, int &sockFD,_
char* &txBuffer, struct sockaddr_ll &socket_address);

int main(int argc, char *argv[]) {
    unsigned char sourceMAC[6];
    unsigned char destMAC[6] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
    bool txMode = true;
    char* txBuffer = (char*)operator new(ETH_FRAME_LEN);
    unsigned char* txEtherhead = (unsigned char*)txBuffer;
    struct ethhdr *eh = (struct ethhdr *)txEtherhead;
    int sockFD;
    char* txData = txBuffer + headersLength;
    struct sockaddr_ll socket_address;
    int sendresult = 0;

    signal (SIGINT,signal_handler(txMode, txData, sendresult, sockFD, txBuffer,_
    socket_address));

    return 0;
}

void signal_handler(bool &txMode, char* &txData, int &sendresult, int &sockFD,_
char* &txBuffer, struct sockaddr_ll &socket_address) {

  if(txMode==true) {
    std::string param;
    std::stringstream ss;
    ss << "etheratedeath";
    param = ss.str();
    strncpy(txData,param.c_str(), param.length());
    sendresult = sendto(sockFD, txBuffer, ETH_FRAME_LEN, 0, 
             (struct sockaddr*)&socket_address, sizeof(socket_address));
  }
  cout << "You killed me!" << endl;
}

I am getting the following error at compile time;

user@machine:~/c/ethernet1$ gcc -o ethernet1 ethernet1.cpp -lrt
ethernet1.cpp: In function ‘int main(int, char**)’:
ethernet1.cpp:358: error: invalid use of void expression

Which refers to this line in main();

signal (SIGINT,signal_handler(txMode, txData, sendresult, sockFD, txBuffer, socket_address));
  • 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-10T02:42:42+00:00Added an answer on June 10, 2026 at 2:42 am

    is this actually achievable or am I misinformed?

    For this to work you need a construct called a closure, Neither C nor C++ have closures built in. However you can implement closure behaviour using the ffcall library. The idea is to build an in-situ function from a generic handler and arguments to be passed to that function. The arguments, of course must remain valid even if the scope is left, which means, either have them be global variables, or allocate them on the heap.

    I am getting the following error at compile time;
    (…)

    signal (SIGINT,signal_handler(txMode, txData, sendresult, sockFD, txBuffer, socket_address));
    

    Now please think about what you did write there and how the compiler does interpret this. Function parameters are passed by value. So the expression signal_handler(…) is evaluated and the result passed to signal. This is not what you want, you want signal_handler being called with the arguments you passed when SIGINT arrives. But this is not, what this line expresses. What it expresses is: Call signal_handler with the parameters now, and pass the result of this as handler parameter to signal for later calling when SIGINT arrives.

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

Sidebar

Related Questions

I am trying to pass some data into my Controller, but I'm getting a
I'm trying to pass some parameter to a function used as callback , how
I'm trying to pass some arguments into a new Powershell remoting session using the
I am trying to pass some extra data when I pass an intent to
I'm trying to pass some data from one activity to a new one but
I've got a MS DOS command line issue, I'm trying to pass some arguments
hi im trying to pass some values to a class but it wont let
im trying to pass some parameters from my a4j:mediaOutput to my bean. I can
i have been trying to pass some variables to model through the controller function
I'm trying to pass some files from one app to another. I communicate the

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.