leadedge / ofxNDI

An Openframeworks addon to allow sending and receiving images over a network using the NewTek Network Device Protocol.
GNU General Public License v3.0
134 stars 48 forks source link

cast string to (char*) #30

Closed dimitre closed 2 years ago

dimitre commented 2 years ago

so it doesn't complain in c++11

leadedge commented 2 years ago

There should be no harm in a cast like that but I don't see why it would be necessary.

This code was taken from the early NDI Version 2 "NDIlib_Send_Video_Advanced" C++ example. Examples from Version 3 onwards initialize NDI_connection_type.p_data directly with default 0 for string length and "NDIlib_send_timecode_synthesize" for the timecode.

To bring it up to date we would have :

NDIlib_metadata_frame_t NDI_connection_type;
NDI_connection_type.p_data = "<ndi_product long_name=\"ofxNDI sender\" "
                 "             short_name=\"ofxNDI Sender\" "
                 "             manufacturer=\"spout@zeal.co\" "
                 "             version=\"1.004.000\" "
                 "             session=\"default\" "
                 "             model_name=\"none\" "
                 "             serial=\"none\"/>";
p_NDILib->send_add_connection_metadata(pNDI_send, &NDI_connection_type);

Would that still cause a warning in your environment?

dimitre commented 2 years ago

Yeah sure it is no problem to be as it is here is the warning, just for information

ISO C++11 does not allow conversion from string literal to 'char *'

Screen Shot 2021-12-28 at 15 15 15

leadedge commented 2 years ago

OK thanks for clarifying that.

I understand from what you say that the current NDI example code would also produce such a warning. In that case we could add the char cast before the string as so -

NDIlib_metadata_frame_t NDI_connection_type;
NDI_connection_type.p_data = (char *)"<ndi_product long_name=\"ofxNDI sender\" "
                 "             short_name=\"ofxNDI Sender\" "
                 "             manufacturer=\"spout@zeal.co\" "
                 "             version=\"1.004.000\" "
                 "             session=\"default\" "
                 "             model_name=\"none\" "
                 "             serial=\"none\"/>";
p_NDILib->send_add_connection_metadata(pNDI_send, &NDI_connection_type);

Would that work? I would like to update to the current example code if possible.

leadedge commented 2 years ago

Changes made and checked An NDI SDK problem