Dziwne deklaracje

0

Czy może ktoś zerknąć czy dobrze zdekodowałem te deklaracje, a jeśli nie to gdzie jest błąd? Próbowałem robić metodą clockwise/spiral rule, ale za duży młyn mi z tego wychodzi. Sprawdzenie cdeclem wywala syntax error. Ogólnie C++, ale chyba dla C nie robi różnicy?

int (* (* L [N]) (int (*) (int)))(int (* f) (int));

L is an array of size N of pointers to function (that takes pointer to function, that takes int and returns int) that returns pointer to function (that takes 'f' which is a pointer to function that takes int and returns int) that returns int.

int * (* z[N]) (int * (*[]) (int * (*[])(int * [])));

z is an array of size N of pointers to function (that takes array of pointers to function [that takes array of pointers to function {that takes an array (?) and returns pointer to int} that returns pointer to int] that returns pointer to int) that returns pointer to int.

thx

1

A to się w ogóle kompiluje? Też mi się wydaje że syntax error, ale ewidentnie ma to coś wspólnego z tablicą wskaźników na funkcje zwracające int* i int coś mi się jednak nawiasy nie zgadzają. Generalnie jednak chyba ten opis co podałeś jest dobry
Nie wiem po co ci to jest, ale to niepokojące. Chyba że na studia. Jak w pracy to wiej. To nie jest dobry kod xD

1

Gdy przyjmiemy #define N 10:

declare L as array 10 of pointer to function (pointer to function (int) returning int) returning pointer to function (pointer to function (int) returning int) returning int

Kompilator (gcc) przełknął taką składnię.

declare z as array 10 of pointer to function (array of pointer to function (array of pointer to function (array of pointer to int) returning pointer to int) returning pointer to int) returning pointer to int

1

Robisz to w ramach jakichś ćwiczeń? Nie widziałem nigdy powodu aby się z tym użerać, mamy przecież aliasy: https://dev.krzaq.cc/post/readable-function-pointers/

1 użytkowników online, w tym zalogowanych: 0, gości: 1