Sto cercando di dichiarare una routine di callback in C++ come segue:Che cosa significa l'errore "Tipo incompleto non consentito"?
void register_rename (int (*function) (const char *current, const char *new));
/*------------------------------------------------------------*/
/* WHEN: The callback is called once each time a file is received and
* accepted. (Renames the temporary file to its permanent name)
* WHAT: Renames a file from the given current name to the specified new name.
*/
Tuttavia, ottengo il seguente errore:
line 204: error #70:
incomplete type is not allowed
void register_rename (int (*function) (const char *current, const char *new));
Non sono sicuro di come risolvere questo. Ho altre routine di callback simili dichiarate nello stesso file di intestazione e non ottengo questo errore.
Si prega di aiuto! :)
evidenziazione della sintassi fornisce un utile suggerimento qui ... – ephemient
È inoltre possibile trovare questo più facile da codice se si typedef il pointer di funzione: 'typedef int (* fn) (const char *, const char * newStr); void register_rename (fn); ' –
Inoltre,' void register_rename (int (*) (const char *, const char *)); 'è un prototipo equivalente; i nomi non sono necessari. – ephemient