Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Using the comma operator to typedef 2 function pointer types

I can do

typedef int a, b;

but I can’t do something like

typedef void(*the_name_1, *the_name_2)(...);

Is there a way do to typedef 2 function pointer types at the same time ?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Multiple declaration in C/C++ is misleading as * is linked to variable and not to the type:

typedef int a, *b, (*c)();

static_assert(std::is_same_v<int, a>);
static_assert(std::is_same_v<int*, b>);
static_assert(std::is_same_v<int (*)(), c>);

So your one-liner would be

typedef void(*the_name_1)(...), (*the_name_2)(...);
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading