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

Surge-VST2: (macOS) Non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list #79

Closed
esaruoho opened this issue Dec 14, 2018 · 7 comments

Comments

@esaruoho
Copy link
Collaborator

am trying to get macOS VST2 to compile and am getting this error in audioeffect.cpp:

Non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list

audioeffect_cpp

What should I do about it?

@esaruoho
Copy link
Collaborator Author

esaruoho commented Dec 14, 2018

Xcode suggests fixing it, so.. if I click on Fix, this:

char temp[2] = {'0' + (char)digit, '\0'};

changes into this:

char temp[2] = {static_cast<char>('0' + (char)digit), '\0'};

is this overall something safe that I can commit to the repo?

@baconpaul
Copy link
Collaborator

That change is OK but a bit weird looking. If I were reviewing the code I would suggest you make it clearer with

Char tmp[ 2 ];
Tmp[ 0 ] = (char)( ‘0’ + (char) digit ); // so 0-9 goes to ‘0’ - ‘9’; and 10 goes to ‘a’
Tmp[ 1 ] = ‘\0’;

Which is basically the same thing just a bit more readable. I’d also ask if someone had confirmed that 0 <= digit < 10 somewhere earlier in the code.

@esaruoho
Copy link
Collaborator Author

@asimilon how did you solve this issue on your branch? :o

@esaruoho esaruoho changed the title macOS:VST2: Non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list Surge-VST2: (macOS) Non-constant-expression cannot be narrowed from type 'int' to 'char' in initializer list Dec 15, 2018
@asimilon
Copy link
Contributor

The only source changes I had to make were removing experimental:: from std::filesystem, like this:

#if MAC
 namespace fs = std::filesystem;
#else
 namespace fs = std::experimental::filesystem;
#endif

everything else compiled as is (for VST2, VST3 had a ton of errors, and AU wouldn't go anywhere due to missing files).

@esaruoho
Copy link
Collaborator Author

@asimilon is this change in a PR and has it been merged? if so, i could always close this ticket :)

@asimilon
Copy link
Contributor

Those changes I detailed above aren't necessary any more (for me at least). I was building successfully without them (XCode9 and brew llvm) after the #92 merge.

@esaruoho
Copy link
Collaborator Author

ok, closing ticket :)

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

3 participants