[CM] s7_complex in C++

chohag at jtan.com chohag at jtan.com
Wed Oct 9 15:27:52 PDT 2024


Hi,

I am linking s7 with a C++ library and the compiler now balks on
the new s7_complex definition:

	./s7.h:351:14: warning: 's7_complex_vector_ref' has C-linkage specified, but returns user-defined type 's7_complex' (aka 'complex<double>') which is incompatible with C [-Wreturn-type-c-linkage]
	  s7_complex s7_complex_vector_ref(s7_pointer vec, s7_int index);
		     ^
	./s7.h:352:14: warning: 's7_complex_vector_set' has C-linkage specified, but returns user-defined type 's7_complex' (aka 'complex<double>') which is incompatible with C [-Wreturn-type-c-linkage]
	  s7_complex s7_complex_vector_set(s7_pointer vec, s7_int index, s7_complex value);
		     ^

This is "solved" by the attached patch which changes the return
type of the offending functions to a s7_complex*. This makes the
compiler happy but obviously this is not the right solution.

I know it's only a warning but a warning is a sign that the compiler
vendor is going to quietly make it undefined behaviour soon and I
don't know C++ well enough to rewrite the macros around the s7_complex
definition into something the compiler would like.

Matthew

-------------- next part --------------
A non-text attachment was scrubbed...
Name: s7-complex.diff
Type: text/x-c
Size: 1726 bytes
Desc: s7-complex.diff
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20241009/941d734f/attachment.bin>


More information about the Cmdist mailing list