-
-
Notifications
You must be signed in to change notification settings - Fork 471
Fixed minor syntax issue in README #524
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
Conversation
Fixed minor syntax issue in C++ example code to improve clarity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR updates the README.md documentation to improve the example code snippet for using TinyGLTF. The example code is wrapped in a complete main() function to make it more practical for users to compile and run directly.
Key changes:
- Wrapped the example code in a proper
main()function with command-line argument handling - Moved the
using namespace tinygltf;declaration inside the function scope - Added explicit
return 0;for successful execution
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
README.md
Outdated
| #include "tiny_gltf.h" | ||
|
|
||
| using namespace tinygltf; | ||
| int main(int /* argc */, char *argv[]){ |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The function definition should have a space before the opening brace. Change main(int /* argc */, char *argv[]){ to main(int /* argc */, char *argv[]) { to follow standard C++ formatting conventions.
| int main(int /* argc */, char *argv[]){ | |
| int main(int /* argc */, char *argv[]) { |
README.md
Outdated
| #include "tiny_gltf.h" | ||
|
|
||
| using namespace tinygltf; | ||
| int main(int /* argc */, char *argv[]){ |
Copilot
AI
Oct 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The argc parameter is commented out but the code uses argv[1] on line 164 without checking if it exists. This will cause a segmentation fault if the program is run without arguments. Either uncomment argc and add a validation check like if (argc < 2), or document that the program requires at least one argument.
| int main(int /* argc */, char *argv[]){ | |
| int main(int argc, char *argv[]){ | |
| if (argc < 2) { | |
| printf("Usage: %s <input.gltf>\n", argv[0]); | |
| return -1; | |
| } |
|
Reviewing the code example in the README, I tried to infer its intent behind it while keeping it as concise as possible, since there are plenty of examples available. As Copilot pointed out, the example will segfault unless arguments are provided. However, I felt adding this detail would clutter the example unnecessarily. @syoyo, what are your thought's on this? |
|
To make code minimal, I think simply use so the code snippet will be like this: |
|
Alright, I see what you mean. It seems this PR would mostly bring us back to the previous implementation, so it’s probably redundant. Thanks for your response and work on the library. Closing this PR. |
|
Modified the usage in this commit: 6d8bba0 |
The original README example contained a small syntax/usage error that could confuse users attempting to compile the sample code directly.
This update improves the reliability of the documentation.