0

What does following line mean?

bool(*)(const GA_Attribute *, void *)   approve = NULL;

where GA_Attribute is custom class.

This line is passed to a function, so I can understand that if user doesn't pass anything then it defaults to NULL.

I do understand type conversion but I have no idea what bool(*) and (const GA_Attribute *, void *) are doing here?

EDIT:

Please see the function declaration here

EDIT 02:

Title is changed from: Pointer explicit type conversion and initialisation in C++

Initially it looked like type conversion to me. Now I understand that it's just Doxygen formatting issue.

PradeepBarua
  • 37
  • 1
  • 12
  • That is a [function pointer](http://stackoverflow.com/questions/840501/how-do-function-pointers-in-c-work) in C. – OpenUserX03 Apr 10 '17 at 16:39
  • 1
    `R (*) (P)` is the type of a function pointer to a function that takes `P` as parameter and returns `R`. There is no type conversion ... – 463035818_is_not_an_ai Apr 10 '17 at 16:39
  • 2
    The above line is not valid C++ or C. The declaration of a function pointer would be `bool(*approve)(const GA_Attribute*, void*) = NULL`. – DeiDei Apr 10 '17 at 16:41
  • The above line is passed to the function like this: `int fillAttribNameMenu (PRM_Name * menu_entries, int max_menu_size, bool(*)(const GA_Attribute *, void *) approve = NULL, void * approve_data = NULL)` – PradeepBarua Apr 10 '17 at 16:47
  • That still [isn't valid C++](http://coliru.stacked-crooked.com/a/1758b9ccc13019f1). – cdhowie Apr 10 '17 at 16:49
  • please see [here](http://www.sidefx.com/docs/hdk/class_s_o_p___node.html#aa1c7a6ec597c9d48d201df103d732908) – PradeepBarua Apr 10 '17 at 16:51
  • A documentation site isn't obligated to present perfectly compileable code in explanations. The fact the site "says so" doesn't mean this is how valid code is written. – StoryTeller - Unslander Monica Apr 10 '17 at 16:54
  • 1
    Aha, that's just weird doc formatting. The [actual declaration](http://www.sidefx.com/docs/hdk/_s_o_p___node_8h_source.html#l01307) uses the correct syntax. So yes, this is just a function pointer as other comments indicate. – cdhowie Apr 10 '17 at 16:54
  • @StoryTeller this' well reputed [3D simulation software](https://en.wikipedia.org/wiki/Houdini_(software))'s documentation and it just compiles fine. – PradeepBarua Apr 10 '17 at 16:58
  • You are missing the point. The documentation and the code need no be the same thing. – StoryTeller - Unslander Monica Apr 10 '17 at 16:59
  • But documentation generates automatically by formatting in Doxygen. Correct me if I'm wrong, I'm not that experienced in C++! – PradeepBarua Apr 10 '17 at 17:02
  • @PradeepBarua The docs generate automatically, but Doxygen is turning a *correct* declaration into a *technically incorrect* declaration. It still conveys the right information to the reader, but the generated declaration in the documentation isn't valid C++. – cdhowie Apr 10 '17 at 17:40
  • Got it! So now this question and it's title doesn't make sense, right? Should it be here? – PradeepBarua Apr 10 '17 at 17:47
  • The title doesn't. The question makes sense *in the context of Doxygen-generated documentation.* – cdhowie Apr 10 '17 at 17:59

0 Answers0