What does “(datatype) (*ptrname) (datatype)” mean? Unicorn Meta Zoo #1: Why another podcast? Announcing the arrival of Valued Associate #679: Cesar Manara Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!What is the difference between #include <filename> and #include “filename”?What does “static” mean in C?What is the effect of extern “C” in C++?What is the meaning of “POSIX”?What does “dereferencing” a pointer mean?What does the C ??!??! operator do?What is “:-!!” in C code?Why does the C preprocessor interpret the word “linux” as the constant “1”?What does set -e mean in a bash script?What 's the meaning of the number 1 in SIG_IGN macro definition?

Map material from china not allowed to leave the country

What *exactly* is electrical current, voltage, and resistance?

Is Bran literally the world's memory?

Expansion//Explosion and Siren Stormtamer

Arriving in Atlanta after US Preclearance in Dublin. Will I go through TSA security in Atlanta to transfer to a connecting flight?

How to keep bees out of canned beverages?

What is this word supposed to be?

Retract an already submitted recommendation letter (written for an undergrad student)

Multiple fireplaces in an apartment building?

"Whatever a Russian does, they end up making the Kalashnikov gun"? Are there any similar proverbs in English?

Putting Ant-Man on house arrest

How to not starve gigantic beasts

What is it called when you ride around on your front wheel?

Error: Syntax error. Missing ')' for CASE Statement

Married in secret, can marital status in passport be changed at a later date?

How would this chord from "Rocket Man" be analyzed?

Why is an operator the quantum mechanical analogue of an observable?

Protagonist's race is hidden - should I reveal it?

How do I check if a string is entirely made of the same substring?

Has a Nobel Peace laureate ever been accused of war crimes?

Split coins into combinations of different denominations

"My boss was furious with me and I have been fired" vs. "My boss was furious with me and I was fired"

Would reducing the reference voltage of an ADC have any effect on accuracy?

How to count in linear time worst-case?



What does “(datatype) (*ptrname) (datatype)” mean?



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar Manara
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!What is the difference between #include <filename> and #include “filename”?What does “static” mean in C?What is the effect of extern “C” in C++?What is the meaning of “POSIX”?What does “dereferencing” a pointer mean?What does the C ??!??! operator do?What is “:-!!” in C code?Why does the C preprocessor interpret the word “linux” as the constant “1”?What does set -e mean in a bash script?What 's the meaning of the number 1 in SIG_IGN macro definition?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















1) I am currently trying to understand the following code, but I can't understand what void(*func)(void) means, I can understand that I am trying to save a the address of function named "function" from list0513, at void pointer func, but what does the casting (void) just before the equal sign mean?



// list0513.c
#include <dlfcn.h>
int main(void)

void *handle = dlopen("./list0513.so", RTLD_LAZY);
void (*func)(void) = dlsym(handle, "function");
(*func)();
dlclose (handle);
return 0;



According to the book, the function called "function" is called from the following script



// list0513dl.c
#include <stdio.h>
void function(void)

printf("Hello Worldn");



2) but how do I make a list0513.so file? the only files I've made are .c files...
Thanks for reading this.










share|improve this question
























  • func is a pointer to a function; *func is a function that takes no parameters and doesn't return a value: returntype (*func)(paramlist) = void (*func)(void)

    – Lorinczy Zsigmond
    Mar 9 at 5:06











  • ad2: gcc -shared -o list0513.so -fPIC llist0513dl.c

    – Lorinczy Zsigmond
    Mar 9 at 5:09











  • @LorinczyZsigmond thanks!! I've forgotten the format!.. Alright! I'll try it! thanks a lot, really

    – 이준영
    Mar 9 at 5:10


















0















1) I am currently trying to understand the following code, but I can't understand what void(*func)(void) means, I can understand that I am trying to save a the address of function named "function" from list0513, at void pointer func, but what does the casting (void) just before the equal sign mean?



// list0513.c
#include <dlfcn.h>
int main(void)

void *handle = dlopen("./list0513.so", RTLD_LAZY);
void (*func)(void) = dlsym(handle, "function");
(*func)();
dlclose (handle);
return 0;



According to the book, the function called "function" is called from the following script



// list0513dl.c
#include <stdio.h>
void function(void)

printf("Hello Worldn");



2) but how do I make a list0513.so file? the only files I've made are .c files...
Thanks for reading this.










share|improve this question
























  • func is a pointer to a function; *func is a function that takes no parameters and doesn't return a value: returntype (*func)(paramlist) = void (*func)(void)

    – Lorinczy Zsigmond
    Mar 9 at 5:06











  • ad2: gcc -shared -o list0513.so -fPIC llist0513dl.c

    – Lorinczy Zsigmond
    Mar 9 at 5:09











  • @LorinczyZsigmond thanks!! I've forgotten the format!.. Alright! I'll try it! thanks a lot, really

    – 이준영
    Mar 9 at 5:10














0












0








0








1) I am currently trying to understand the following code, but I can't understand what void(*func)(void) means, I can understand that I am trying to save a the address of function named "function" from list0513, at void pointer func, but what does the casting (void) just before the equal sign mean?



// list0513.c
#include <dlfcn.h>
int main(void)

void *handle = dlopen("./list0513.so", RTLD_LAZY);
void (*func)(void) = dlsym(handle, "function");
(*func)();
dlclose (handle);
return 0;



According to the book, the function called "function" is called from the following script



// list0513dl.c
#include <stdio.h>
void function(void)

printf("Hello Worldn");



2) but how do I make a list0513.so file? the only files I've made are .c files...
Thanks for reading this.










share|improve this question
















1) I am currently trying to understand the following code, but I can't understand what void(*func)(void) means, I can understand that I am trying to save a the address of function named "function" from list0513, at void pointer func, but what does the casting (void) just before the equal sign mean?



// list0513.c
#include <dlfcn.h>
int main(void)

void *handle = dlopen("./list0513.so", RTLD_LAZY);
void (*func)(void) = dlsym(handle, "function");
(*func)();
dlclose (handle);
return 0;



According to the book, the function called "function" is called from the following script



// list0513dl.c
#include <stdio.h>
void function(void)

printf("Hello Worldn");



2) but how do I make a list0513.so file? the only files I've made are .c files...
Thanks for reading this.







c linux dll






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 9 at 5:46









jww

54.6k42240522




54.6k42240522










asked Mar 9 at 4:59









이준영이준영

6




6












  • func is a pointer to a function; *func is a function that takes no parameters and doesn't return a value: returntype (*func)(paramlist) = void (*func)(void)

    – Lorinczy Zsigmond
    Mar 9 at 5:06











  • ad2: gcc -shared -o list0513.so -fPIC llist0513dl.c

    – Lorinczy Zsigmond
    Mar 9 at 5:09











  • @LorinczyZsigmond thanks!! I've forgotten the format!.. Alright! I'll try it! thanks a lot, really

    – 이준영
    Mar 9 at 5:10


















  • func is a pointer to a function; *func is a function that takes no parameters and doesn't return a value: returntype (*func)(paramlist) = void (*func)(void)

    – Lorinczy Zsigmond
    Mar 9 at 5:06











  • ad2: gcc -shared -o list0513.so -fPIC llist0513dl.c

    – Lorinczy Zsigmond
    Mar 9 at 5:09











  • @LorinczyZsigmond thanks!! I've forgotten the format!.. Alright! I'll try it! thanks a lot, really

    – 이준영
    Mar 9 at 5:10

















func is a pointer to a function; *func is a function that takes no parameters and doesn't return a value: returntype (*func)(paramlist) = void (*func)(void)

– Lorinczy Zsigmond
Mar 9 at 5:06





func is a pointer to a function; *func is a function that takes no parameters and doesn't return a value: returntype (*func)(paramlist) = void (*func)(void)

– Lorinczy Zsigmond
Mar 9 at 5:06













ad2: gcc -shared -o list0513.so -fPIC llist0513dl.c

– Lorinczy Zsigmond
Mar 9 at 5:09





ad2: gcc -shared -o list0513.so -fPIC llist0513dl.c

– Lorinczy Zsigmond
Mar 9 at 5:09













@LorinczyZsigmond thanks!! I've forgotten the format!.. Alright! I'll try it! thanks a lot, really

– 이준영
Mar 9 at 5:10






@LorinczyZsigmond thanks!! I've forgotten the format!.. Alright! I'll try it! thanks a lot, really

– 이준영
Mar 9 at 5:10













2 Answers
2






active

oldest

votes


















0














The declaration reads as follows:



 func — func
*func — is a pointer to
(*func)( ) — a function taking
(*func)(void) — no parameters
void (*func)(void) — returning void


The func pointer is then initialized with the result of the dlsym call, which returns the address of the function ”function” in the library list0513.so.



General declaration rules for pointer types:



T *p; // p is a pointer to T
T *p[N]; // p is an array of pointer to T
T (*p)[N]; // p is a pointer to an array of T
T *f(); // f is a function returning a pointer to T
T (*f)(); // f is a pointer to a function returning T


In both declarations and expressions, the postfix [] subscript and () function call operators have higher precedence than unary *, so *f() is parsed as *(f()) (function returning pointer). To declare a pointer to an array or function, the * has to be explicitly grouped with the array or function declarator.



Declarations can get pretty complex - you can have an array of pointers to functions:



T (*a[N])(); // a is an array of pointers to functions returning T


or functions returning pointers to arrays:



T (*f())[N]; // f is a function returning a pointer to an array


or even pointers to arrays of pointers to functions returning pointers to arrays:



T (*(*(*a)[N])())[M];


You probably won’t see anything that hairy in the wild, though (unless you run across some old code of mine).






share|improve this answer






























    -1














    It is omitted a declare of function type. The full or expended version should like this:



    // list0513.c
    #include <dlfcn.h>
    int main(void)

    void *handle = dlopen("./list0513.so", RTLD_LAZY);
    typedef void(*FUNC)();
    FUNC func = dlsym(handle, "function");
    func(); // call function
    dlclose (handle);
    return 0;






    share|improve this answer























    • No, it is not a function type but a pointer-to-a-function type.

      – Antti Haapala
      Mar 9 at 7:11











    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074134%2fwhat-does-datatype-ptrname-datatype-mean%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The declaration reads as follows:



     func — func
    *func — is a pointer to
    (*func)( ) — a function taking
    (*func)(void) — no parameters
    void (*func)(void) — returning void


    The func pointer is then initialized with the result of the dlsym call, which returns the address of the function ”function” in the library list0513.so.



    General declaration rules for pointer types:



    T *p; // p is a pointer to T
    T *p[N]; // p is an array of pointer to T
    T (*p)[N]; // p is a pointer to an array of T
    T *f(); // f is a function returning a pointer to T
    T (*f)(); // f is a pointer to a function returning T


    In both declarations and expressions, the postfix [] subscript and () function call operators have higher precedence than unary *, so *f() is parsed as *(f()) (function returning pointer). To declare a pointer to an array or function, the * has to be explicitly grouped with the array or function declarator.



    Declarations can get pretty complex - you can have an array of pointers to functions:



    T (*a[N])(); // a is an array of pointers to functions returning T


    or functions returning pointers to arrays:



    T (*f())[N]; // f is a function returning a pointer to an array


    or even pointers to arrays of pointers to functions returning pointers to arrays:



    T (*(*(*a)[N])())[M];


    You probably won’t see anything that hairy in the wild, though (unless you run across some old code of mine).






    share|improve this answer



























      0














      The declaration reads as follows:



       func — func
      *func — is a pointer to
      (*func)( ) — a function taking
      (*func)(void) — no parameters
      void (*func)(void) — returning void


      The func pointer is then initialized with the result of the dlsym call, which returns the address of the function ”function” in the library list0513.so.



      General declaration rules for pointer types:



      T *p; // p is a pointer to T
      T *p[N]; // p is an array of pointer to T
      T (*p)[N]; // p is a pointer to an array of T
      T *f(); // f is a function returning a pointer to T
      T (*f)(); // f is a pointer to a function returning T


      In both declarations and expressions, the postfix [] subscript and () function call operators have higher precedence than unary *, so *f() is parsed as *(f()) (function returning pointer). To declare a pointer to an array or function, the * has to be explicitly grouped with the array or function declarator.



      Declarations can get pretty complex - you can have an array of pointers to functions:



      T (*a[N])(); // a is an array of pointers to functions returning T


      or functions returning pointers to arrays:



      T (*f())[N]; // f is a function returning a pointer to an array


      or even pointers to arrays of pointers to functions returning pointers to arrays:



      T (*(*(*a)[N])())[M];


      You probably won’t see anything that hairy in the wild, though (unless you run across some old code of mine).






      share|improve this answer

























        0












        0








        0







        The declaration reads as follows:



         func — func
        *func — is a pointer to
        (*func)( ) — a function taking
        (*func)(void) — no parameters
        void (*func)(void) — returning void


        The func pointer is then initialized with the result of the dlsym call, which returns the address of the function ”function” in the library list0513.so.



        General declaration rules for pointer types:



        T *p; // p is a pointer to T
        T *p[N]; // p is an array of pointer to T
        T (*p)[N]; // p is a pointer to an array of T
        T *f(); // f is a function returning a pointer to T
        T (*f)(); // f is a pointer to a function returning T


        In both declarations and expressions, the postfix [] subscript and () function call operators have higher precedence than unary *, so *f() is parsed as *(f()) (function returning pointer). To declare a pointer to an array or function, the * has to be explicitly grouped with the array or function declarator.



        Declarations can get pretty complex - you can have an array of pointers to functions:



        T (*a[N])(); // a is an array of pointers to functions returning T


        or functions returning pointers to arrays:



        T (*f())[N]; // f is a function returning a pointer to an array


        or even pointers to arrays of pointers to functions returning pointers to arrays:



        T (*(*(*a)[N])())[M];


        You probably won’t see anything that hairy in the wild, though (unless you run across some old code of mine).






        share|improve this answer













        The declaration reads as follows:



         func — func
        *func — is a pointer to
        (*func)( ) — a function taking
        (*func)(void) — no parameters
        void (*func)(void) — returning void


        The func pointer is then initialized with the result of the dlsym call, which returns the address of the function ”function” in the library list0513.so.



        General declaration rules for pointer types:



        T *p; // p is a pointer to T
        T *p[N]; // p is an array of pointer to T
        T (*p)[N]; // p is a pointer to an array of T
        T *f(); // f is a function returning a pointer to T
        T (*f)(); // f is a pointer to a function returning T


        In both declarations and expressions, the postfix [] subscript and () function call operators have higher precedence than unary *, so *f() is parsed as *(f()) (function returning pointer). To declare a pointer to an array or function, the * has to be explicitly grouped with the array or function declarator.



        Declarations can get pretty complex - you can have an array of pointers to functions:



        T (*a[N])(); // a is an array of pointers to functions returning T


        or functions returning pointers to arrays:



        T (*f())[N]; // f is a function returning a pointer to an array


        or even pointers to arrays of pointers to functions returning pointers to arrays:



        T (*(*(*a)[N])())[M];


        You probably won’t see anything that hairy in the wild, though (unless you run across some old code of mine).







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 9 at 13:29









        John BodeJohn Bode

        84.1k1378153




        84.1k1378153























            -1














            It is omitted a declare of function type. The full or expended version should like this:



            // list0513.c
            #include <dlfcn.h>
            int main(void)

            void *handle = dlopen("./list0513.so", RTLD_LAZY);
            typedef void(*FUNC)();
            FUNC func = dlsym(handle, "function");
            func(); // call function
            dlclose (handle);
            return 0;






            share|improve this answer























            • No, it is not a function type but a pointer-to-a-function type.

              – Antti Haapala
              Mar 9 at 7:11















            -1














            It is omitted a declare of function type. The full or expended version should like this:



            // list0513.c
            #include <dlfcn.h>
            int main(void)

            void *handle = dlopen("./list0513.so", RTLD_LAZY);
            typedef void(*FUNC)();
            FUNC func = dlsym(handle, "function");
            func(); // call function
            dlclose (handle);
            return 0;






            share|improve this answer























            • No, it is not a function type but a pointer-to-a-function type.

              – Antti Haapala
              Mar 9 at 7:11













            -1












            -1








            -1







            It is omitted a declare of function type. The full or expended version should like this:



            // list0513.c
            #include <dlfcn.h>
            int main(void)

            void *handle = dlopen("./list0513.so", RTLD_LAZY);
            typedef void(*FUNC)();
            FUNC func = dlsym(handle, "function");
            func(); // call function
            dlclose (handle);
            return 0;






            share|improve this answer













            It is omitted a declare of function type. The full or expended version should like this:



            // list0513.c
            #include <dlfcn.h>
            int main(void)

            void *handle = dlopen("./list0513.so", RTLD_LAZY);
            typedef void(*FUNC)();
            FUNC func = dlsym(handle, "function");
            func(); // call function
            dlclose (handle);
            return 0;







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 9 at 6:07









            YuanhuiYuanhui

            312212




            312212












            • No, it is not a function type but a pointer-to-a-function type.

              – Antti Haapala
              Mar 9 at 7:11

















            • No, it is not a function type but a pointer-to-a-function type.

              – Antti Haapala
              Mar 9 at 7:11
















            No, it is not a function type but a pointer-to-a-function type.

            – Antti Haapala
            Mar 9 at 7:11





            No, it is not a function type but a pointer-to-a-function type.

            – Antti Haapala
            Mar 9 at 7:11

















            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074134%2fwhat-does-datatype-ptrname-datatype-mean%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            AWS Lex not identifying response if by a variable The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) The Ask Question Wizard is Live! Data science time! April 2019 and salary with experienceEnforcing custom enumeration in AWS LEX for slot valuesHow to give response based on user response in Amazon Lex?Intercepting AWS Lambda Response to a AWS Lex QueryLex chat bot error: Reached second execution of fulfillment lambda on the same utteranceamazon lex showing invalid responseLambda response send back to Lex slot?Response card in Amazon lexAmazon Lex - Lambda response return HTML to botHow can I solve 424 (Failed Dependency) (python) obtained from Amazon lex?

            Алба-Юлія

            Захаров Федір Захарович