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

Fixed C & C++ compatibility #12

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

monoamine11231
Copy link

I noticed the header file was created to allow C & C++ compatibility for this library, but the code itself was much raw C with some exceptions that do not make it possible for it to compile in C.

The following changes were made to make this library compatible with both C++ and C:

  • Included the C headers if C and the C++ headers if C++ (<cmath> in C++, but <math.h> in C)
  • using namespace std if C++ (no std:: in C)
  • typedef struct zbuf zbuf; typedef struct zhuffman zhuffman if C (must be done explicitly in C)
  • Proper C-style (same in C++) type casting of values, ex: (int)your_float instead of int(your_float)
  • Replaced shadowed struct mixbox_init_t with what it is supposed to do (call decompress)

What's next?

  • If accepting my pull request don't forget to update mixbox_lut_compressed with the new code

P.S: When compiling the library in C, you need to link it with math library (-lm option in gcc)
Have a good day.

@monoamine11231 monoamine11231 changed the title C cpp compatibility Fixed C & C++ compatibility Dec 16, 2022
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

Successfully merging this pull request may close these issues.

2 participants