Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generated C++ code for variable length data may not compile #796

Closed
rogerorr opened this issue Jun 23, 2020 · 4 comments
Closed

Generated C++ code for variable length data may not compile #796

rogerorr opened this issue Jun 23, 2020 · 4 comments

Comments

@rogerorr
Copy link
Contributor

There seems to be a potential case mismatch when using a schema file with a variable length field.

There is inconsistent handling of the case of the first letter of the field name.

The C++ generated code creates an accessor method such as:
static SBE_CONSTEXPR std::uint64_t exampleHeaderLength() SBE_NOEXCEPT
but then attempts to call it inside:
SBE_NODISCARD static size_t computeLength(std::size_t ExampleLength = 0)
by invoking it as:
length += ExampleHeaderLength();

I encountered the issue updating from 1.12.2 to 1.82.2 and have reproduced it with the current code by changing the case of the last field in sbe-tool/src/test/resources/code-generation-schema.xml from "color" to "Color":

java -Dsbe.target.language=CPP -Dsbe.target.namespace=test -jar sbe-all/build/libs/sbe-all-1.19.0-SNAPSHOT.jar sbe-tool/src/test/resources/code-generation-schema.xml

Testing the output:

g++ -c test/Car.h
test/car.h: In static member function 'static size_t test::Car::computeLength(const std::vector<std::tuple<long unsigned int> >&, const std::vector<std::tuple<long unsigned int> >&, std::size_t, std::size_t, std::size_t, std::size_t)':
test/car.h:3202:15: error: 'ColorHeaderLength' was not declared in this scope; did you mean 'colorHeaderLength'?
 3202 |     length += ColorHeaderLength();
      |               ^~~~~~~~~~~~~~~~~
      |               colorHeaderLength
@mjpt777
Copy link
Contributor

mjpt777 commented Jun 23, 2020

This is a duplicate of #795 which has been fixed and will make the next release.

@mjpt777 mjpt777 closed this as completed Jun 23, 2020
@rogerorr
Copy link
Contributor Author

This problem does not appear to be fixed by the resolution of #795.

(1) The example change of "color" -> "Color" in the test schema still generates bad code with the current master (3b0d3f6).

(2) #795 is referring to the same method but it is describing a different problem -- an interaction with constexpr.

@mjpt777
Copy link
Contributor

mjpt777 commented Jun 23, 2020

@rogerorr Try building with head now.

@rogerorr
Copy link
Contributor Author

Thanks, the codegen looks good now.

@mjpt777 mjpt777 closed this as completed Jun 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants