user1242967 user1242967 - 1 year ago 55
C Question

Long function declaration line. What are the conventions for splitting it?

Here is the declaration

dll_DoublyLinkedNode *dll_search(const dll_DoublyLinkedList list, void *key, int (*compare)(void *data, void *key)){

Should I split it? Should I just leave it as it is? Perhaps I should do something different?

Answer Source

This is completely a matter of taste, but I'd be a fan of something along the lines of:

dll_DoublyLinkedNode *dll_search(
  const dll_DoublyLinkedList list, 
  void *key, 
  int (*compare)(void *data, void *key)

Additionally, you could typedef the function pointer type you reference and give it a handy name.