microsoft / yardl

Tooling for streaming instrument data
https://microsoft.github.io/yardl/
MIT License
29 stars 5 forks source link

Empty protocol results in an invalid C++ CopyTo method #136

Closed naegelejd closed 3 months ago

naegelejd commented 4 months ago

Currently, yardl permits an empty Protocol (one with zero steps in its sequence).

In C++ codegen, an empty Protocol results in an unused writer parameter in the protocol reader's CopyTo method.

Model:

MyProtocol: !protocol
  sequence:

Generated CopyTo method:

void MyProtocolReaderBase::CopyTo(MyProtocolWriterBase& writer) {
}

Compiler error:

[2/7] Building CXX object generated/CMakeFiles/issue_generated.dir/protocols.cc.o
FAILED: generated/CMakeFiles/issue_generated.dir/protocols.cc.o 
...
.../cpp/generated/protocols.cc: In member function 'void issue::MyProtocolReaderBase::CopyTo(issue::MyProtocolWriterBase&)':
/workspaces/yardl/joe/issue-#ddd/cpp/generated/protocols.cc:73:57: error: unused parameter 'writer' [-Werror=unused-parameter]
   73 | void MyProtocolReaderBase::CopyTo(MyProtocolWriterBase& writer) {
      |                                   ~~~~~~~~~~~~~~~~~~~~~~^~~~~~
cc1plus: all warnings being treated as errors

Either empty Protocols should not be permitted, or I'll add a cast to void to silence the compiler.

naegelejd commented 4 months ago

@johnstairs Should yardl continue to allow empty protocols?