Hello i was using c2nim to try to convert a group of header files to nim but some code where omitted. Now this is not to much of a problem because i was able to fix most of them on my own. But i am no expert in c or cpp so there are some lines of code i could not convert because i do not understand the function of those code, so i would appreciate the c/cpp juggernauts to help.
#ifndef NDILIB_CPP_DEFAULT_VALUE
# ifdef __cplusplus
# define NDILIB_CPP_DEFAULT_VALUE(a) = (a)
define NDILIB_CPP_DEFAULT_VALUE(a) = (a) please can someone explain this code to me. I know it's defining a constant but the constant has a parameter and the constant then takes the value of the parameter. I also know this could be a template but i still do not under the purpose of this. I feel like NDILIB_CPP_DEFAULT_VALUE could just be equated to the a value.
And another piece of code is
NDIlib_recv_instance_t NDIlib_recv_create_v3(const NDIlib_recv_create_v3_t* p_create_settings NDILIB_CPP_DEFAULT_VALUE(NULL));
my problem with this is NDILIB_CPP_DEFAULT_VALUE(NULL) it's neither a parameter nor a value to a parameter so what's it's use.
AND BEFORE ANYONE TELLS ME TO SEARCH THE INTERNET FOR ANSWERS. I ALREADY DID THAT'S WHY I AM HERE. Any help is appreciated thanks.
I think it is not that hard to guess what the macro does. First line checks if NDILIB_CPP_DEFAULT_VALUE is not defined. When you convert to Nim code this is generally true (undefined.) Next line checks if we compile in cpp mode. If that is the case (I would guess yes) then the macro call NDILIB_CPP_DEFAULT_VALUE(a) is defined as as NOP (no operation) as it is equal to (a). That would mean that you can replace each "NDILIB_CPP_DEFAULT_VALUE" call with nothing, so delete it. You other code line then gets
NDIlib_recv_instance_t NDIlib_recv_create_v3(const NDIlib_recv_create_v3_t* p_create_settings (NULL));
As I said, that is more guessing, I have not much practice in C and C++. (Don't ask me what would happen if you would compile the C++ code in C mode, so that __cplusplus is undefined.) Maybe other people can tell you more later.