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

C function type without a typedef

Suppose we have many C functions with the same signature and return type:

R f(X x,Y y){...}
R g(X x,Y y){...}
R h(X x,Y y){...}

where X and Y are the types of the arguments and R is the type of the result.

We can declare those functions, for instance in a header file or as forward declarations, like this:

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

R f(X,Y);R g(X,Y);R h(X,Y);

or more concisely:

R f(X,Y),g(X,Y),h(X,Y);

or, avoiding most repetition:

typedef R F(X,Y);
F f,g,h;

Can that be done in a single statement, without a separate typedef?

>Solution :

I have not checked yet but maybe in C23 there is possible to write

typeof( R( X, Y ) ) f, g, h;
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