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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:30:13+00:00 2026-05-16T21:30:13+00:00

I came across this piece of code and completely got lost interpreting its meaning.

  • 0

I came across this piece of code and completely got lost interpreting its meaning.

#include <signal.h>
void (*signal(int sig, void (*func)(int)))(int);

What is a detailed explanation for the code at line 2?

I know that void and int are types, the *func is a pointer for a function, and the brackets are for priority. But I still don’t get the (*signal …), the (int), and the whole thing combined together. The more detailed, the better.

Probably I’ve known the meaning/effect of this declaration. But I had to make some more trials to help me understand what’s going on, as below:

  1 #include <signal.h>
  2 void (*signal)(int sig, void (*func)(int));
  3 void (*signal)(int);  // then void (signal)(int) again.
  4 //void (*signal(int sig, void (*func)(int)))(int); //break this line into two lines above
  5
  6 int main(){}

In the above code, I broke void (*signal(int sig, void (*func)(int)))(int) into two lines. For line 3, I tried both void (*signal)(int) and void (signal)(int), with the same error result that indicated that I was trying to redeclare signal:

TestDeclaration.c:2: error: ‘signal’ redeclared as different kind of symbol
/usr/include/signal.h:93: error: previous declaration of ‘signal’ was here
TestDeclaration.c:3: error: ‘signal’ redeclared as different kind of symbol
/usr/include/signal.h:93: error: previous declaration of ‘signal’ was here

Now I know both the trials are incorrect ways of declaration, but why are they incorrect? Why is the original way of declaration NOT a redeclaration?

  • 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-05-16T21:30:13+00:00Added an answer on May 16, 2026 at 9:30 pm

    It’s the declaration of a function taking an int and a pointer to a function (taking int returning void) and returning a pointer to a function (taking int and returning void).


    Explanation, or guide to interpretation

    You can interpret by treating everything in parentheses as a single entity and then working inwards using the "declaration follows usage" rule.

    void (*signal(int sig, void (*func)(int)))(int);

    The entity in the brackets looks like a function taking int and returning void.

    Stripping away the outer part:

    *signal(int sig, void (*func)(int))
    

    So, signal takes some parameters and returns something that can be dereferenced (due to the leading *) to form a function taking int and returning void.

    This means signal is a function returning a pointer to a function (taking int and returning void).

    Looking at the parameters it takes an int (i.e. sig) and void (*func)(int) which is a pointer to a function (taking int and returning void).

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

Sidebar

Related Questions

I came across this problem when referring a piece of JavaScript code: <a href="javascript:void(0);"><!--
Watching some code found on internet I came across this piece of code: int
just wondering if someone else came across this. I got this piece of code
I came across this piece of code: void incme(double *p) { *p += 1;
Today I came across this piece of code internal object UpdatePracownik(object employee) { lock
I was looking at the YUI Compressor and came across this piece of code
I came across this piece of batch code. It should find the path to
I came across this piece of code today: File.SetAttributes(excelFileName, File.GetAttributes(excelFileName) & ~ (FileAttributes.Archive |
I was going over a piece of code, and i came across this regular
I came across this piece of code where programmer determines uploaded file size like

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.