Search code examples
cdeclarationfunction-declaration

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:

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;