eclipse-cyclonedds / cyclonedds

Eclipse Cyclone DDS project
https://projects.eclipse.org/projects/iot.cyclonedds
Other
889 stars 363 forks source link

An implementation for dds_stream_writeLE could not be found #2060

Closed ff20509 closed 3 weeks ago

ff20509 commented 3 months ago

Hello, why did I search globally for the dds_stream_writeLE function and only found the function declaration but not the implementation?

dpotman commented 3 months ago

To avoid code duplication for the little-endian, big-endian and native byte order variants of these functions, we use an include file with a generic implementation. The definition for this function is in dds_cdrstream_write.part.h that is included here.

ff20509 commented 3 months ago

Thanks for the answer, I still have some premature questions. Is dds_stream_writeLE and dds_stream_writeBE the common implementation of dds_stream_writeBO?I see that the header of dds_cdrstream.c has the macro definition #define dds_stream_writeBO NAME_BYTE_ORDER(dds_stream_write), But it does not include the file dds_cdrstream_write.part.h until after it. There seems to be a missing step to make a connection between dds_stream_writeLE and dds_stream_writeBO.

dpotman commented 3 months ago

dds_stream_writeBO is a macro that is expanded each time dds_cdrstream_write.part.h is included, and the NAME_BYTE_ORDER macro concatenates the function name (dds_stream_write) and the byte order extension (LE, BE or empty string for native) that results in the actual function name (as declared in dds_cdrstream.h) The function body is expanded three times for these three function names.

eboasson commented 3 weeks ago

Presumed answered in sufficient detail.