glideapps / quicktype

Generate types and converters from JSON, Schema, and GraphQL
https://app.quicktype.io
Apache License 2.0
12.43k stars 1.08k forks source link

C++: multi-source files + generators #1026

Open harsszegi opened 6 years ago

harsszegi commented 6 years ago

Hello Mark, just realized a few things:

schani commented 6 years ago

I see. To me the first point is much more problematic, since that's quicktype's default mode of operation.

As to the testing: unfortunately our test suite doesn't currently test multiple top-levels, or it would have caught those issues. I guess that's my responsibility.

PS: If you do fix those, please make a PR for one of them first, and only when we've merged that, for the other one ;-)

flounderpinto commented 5 years ago

I believe that I'm running into this same issue. I only have one single-source generated file in my project, but I'm getting "mulitple definition" linking errors on the two void CheckConstraint(...) methods. Making them inline seems to fix the problem (similar to the inline json get_untyped(...) methods).

Would changing "void" to "inline void" on lines 1771 and 1828 of the below file fix the issue? If so, I'm happy to attempt a pull request.

https://github.com/quicktype/quicktype/blob/1876d6b576fdaed15529afacf3897672ecf372a8/src/quicktype-core/language/CPlusPlus.ts