Non sono sempre uguali.
Prova a fare qualcosa del genere con una macro:
Più in generale il typedef ha grandi potenzialità, e ti permette di fare cose diverse e qualcosa di più complesso rispetto a un #define. Puoi ad esempio definire tipi "complicati" a passi graduali.codice:typedef void (*FUNCTION)(int); ... FUNCTION f;
Preso da qui, una miniera di informazioni...codice:1.21: How do I declare an array of N pointers to functions returning pointers to functions returning pointers to characters? A: The first part of this question can be answered in at least three ways: 1. char *(*(*a[N])())(); 2. Build the declaration up incrementally, using typedefs: typedef char *pc; /* pointer to char */ typedef pc fpc(); /* function returning pointer to char */ typedef fpc *pfpc; /* pointer to above */ typedef pfpc fpfpc(); /* function returning... */ typedef fpfpc *pfpfpc; /* pointer to... */ pfpfpc a[N]; /* array of... */ 3. Use the cdecl program, which turns English into C and vice versa: cdecl> declare a as array of pointer to function returning pointer to function returning pointer to char char *(*(*a[])())() cdecl can also explain complicated declarations, help with casts, and indicate which set of parentheses the arguments go in (for complicated function definitions, like the one above). See question 18.1. Any good book on C should explain how to read these complicated C declarations "inside out" to understand them ("declaration mimics use"). The pointer-to-function declarations in the examples above have not included parameter type information. When the parameters have complicated types, declarations can *really* get messy. (Modern versions of cdecl can help here, too.) References: K&R2 Sec. 5.12 p. 122; ISO Sec. 6.5ff (esp. Sec. 6.5.4); H&S Sec. 4.5 pp. 85-92, Sec. 5.10.1 pp. 149-50.
![]()

Rispondi quotando