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

Compile error: JSON::Value lacks overload for size_t (unsigned long) on MacOS #214

Open
charles-dyfis-net opened this issue Nov 23, 2024 · 6 comments

Comments

@charles-dyfis-net
Copy link

Below is one of many similar errors:

[6/193] Compiling C++ object MistInFLAC.p/src_input_input_flac.cpp.o
FAILED: MistInFLAC.p/src_input_input_flac.cpp.o
clang++ -IMistInFLAC.p -I. -I.. -I../subprojects/mbedtls/include -Isubprojects/libsrtp/include -I../subprojects/libsrtp/include -Imist -fcolor-diagnostics -Wall -Winvalid-pch -std=c++98 -O0 -g -funsigned-char -D_LARGEFILE_SOURCE -Wno-sign-compare -Wparentheses -Wno-non-virtual-dtor -Wno-strict-aliasing '-DAPPNAME="MistServer"' -DDEBUG=4 '-DRELEASE="Generic_aarch64"' '-DPACKAGE_VERSION="3.4"' -DSHM_DATASIZE=40 -DSTAT_CUTOFF=600 -DSTATS_DELAY=15 '-DUDP_API_HOST="localhost"' -DUDP_API_PORT=4242 -DSSL=1 -DUPDATER=1 -DHAVE_UPSTREAM_MBEDTLS_SRTP=0 -DWITH_DATACHANNELS '-DINPUTTYPE="input_flac.h"' -MD -MQ MistInFLAC.p/src_input_input_flac.cpp.o -MF MistInFLAC.p/src_input_input_flac.cpp.o.d -o MistInFLAC.p/src_input_input_flac.cpp.o -c ../src/input/input_flac.cpp
../src/input/input_flac.cpp:199:38: error: use of overloaded operator '=' is ambiguous (with operand types 'Value' and 'size_t' (aka 'unsigned long'))
    meta.inputLocalVars["blockSize"] = blockSize;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~
mist/json.h:62:12: note: candidate function
    Value &operator=(const int64_t &rhs);
           ^
mist/json.h:63:12: note: candidate function
    Value &operator=(const int32_t &rhs);
           ^
mist/json.h:64:12: note: candidate function
    Value &operator=(const uint64_t &rhs);
           ^
mist/json.h:65:12: note: candidate function
    Value &operator=(const uint32_t &rhs);
           ^
mist/json.h:66:12: note: candidate function
    Value &operator=(const double &rhs);
           ^
mist/json.h:67:12: note: candidate function
    Value &operator=(const bool &rhs);
           ^
1 error generated.
charles-dyfis-net added a commit to charles-dyfis-net/mistserver that referenced this issue Nov 23, 2024
@Thulinma
Copy link
Contributor

Cross-referencing #215

@charles-dyfis-net
Copy link
Author

Would making this code conditional with #ifdef __APPLE__ work?

@Thulinma
Copy link
Contributor

It would make it work on Apple, sure (assuming that Apple behaves the same on x86 and arm - which I'm not sure of, honestly). But there are probably other platforms with the same problem, so a comparison of the width of size_t and uint64_t (and possibly also uint32_t, for 32-bit platforms) would be more robust and less Apple-specific.

@charles-dyfis-net
Copy link
Author

My concern there is that I don't understand sizeof() to be available at preprocessor time (admittedly, though, it's been a few decades since I wrote C full time, so my memory is fuzzy).

@Thulinma
Copy link
Contributor

Yup, you're absolutely right. However, thankfully Meson is capable of compiling and running "code snippets" to do these kind of tasks. So we can totally run such a snippet to see if the extra functions are needed or not, and then define a variable based on the outcome.
If this sounds a little too complex for you, no worries, I have been planning to make this change at some point in the near-ish future anyway. Just need to get some other things out of the way first (paying customer requests get priority and all that).

@Thulinma
Copy link
Contributor

My colleague @stronk-dev (whom is also a Mac user) has volunteered to handle this actually! Expect it to land shortly ^_^

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