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

HelloWorld/main.cpp → HelloWorld/main.c #1

Open
3 tasks
LPGhatguy opened this issue Apr 19, 2024 · 4 comments
Open
3 tasks

HelloWorld/main.cpp → HelloWorld/main.c #1

LPGhatguy opened this issue Apr 19, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@LPGhatguy
Copy link
Member

LPGhatguy commented Apr 19, 2024

I think it'd be swell if the HelloWorld example were actually valid C instead of just C-shaped C++. There are a couple issues with the bindings preventing that:

  • Change enums from C23/C++-style enums with reprs to constants
  • Use NULL instead of nullptr
  • Change struct initialization from C++-style Foo{...} to (Foo){...} or {...}.
@LPGhatguy LPGhatguy added the enhancement New feature or request label Apr 19, 2024
@LPGhatguy LPGhatguy changed the title HelloWorld/main.cpp -> HelloWorld/main.c HelloWorld/main.cpp → HelloWorld/main.c Apr 19, 2024
@DagAgren
Copy link

I was messing around with this right now and it seems it mostly is valid C? You need to change nullptr to NULL, and JPC_RVec3{...} to (JPC_RVec3){...}, and it builds just fine?

@DagAgren
Copy link

(However, it does not seem to bounce, which I think it's meant to?)

@LPGhatguy
Copy link
Member Author

I was messing around with this right now and it seems it mostly is valid C? You need to change nullptr to NULL, and JPC_RVec3{...} to (JPC_RVec3){...}, and it builds just fine?

Nice! Those are easy fixes. I didn't realize that C didn't have that style of struct initializer. I bet we can just use {...} in a lot of places.

(However, it does not seem to bounce, which I think it's meant to?)

Ah, you mean that when we compile the same HelloWorld example in the repo as C, the behavior changes? That's not good! 🤔

When I ported the example originally I verified that we got identical output between the original C++ HelloWorld, the new C-ish HelloWorld, and a Rust program using bindings to JoltC.

@DagAgren
Copy link

I didn't try it as .cpp, I needed it refactored a bit to run on iOS and converted to C at the same time.

But I figured it out, it seems the bodies had 0 restitution? If I set it manually it works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants