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

char type is not compatible with all boards #287

Open
tomcombriat opened this issue Nov 10, 2024 · 0 comments
Open

char type is not compatible with all boards #287

tomcombriat opened this issue Nov 10, 2024 · 0 comments

Comments

@tomcombriat
Copy link
Collaborator

Trying to get the AudioDelayFeedbackX2 example to work correctly on the Pico (RP2040) I encountered a weird behavior: char type on the Pico (and maybe some other boards) is unsigned by default. Here is a small example that exemplifies that and all the potential side effects this could have:

char a = -1;

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(sizeof(a));
  Serial.println(a - 1);
  delay(1000);
}

Output:

1
254

Note that it does work with the expected behavior on the UNO or by defining signed char a=-1.


For mozzi, the expected type in most cases is int8_t, which is the same for everyone, hence I think it will be beneficial to have a critical look at every places where char is used and change it when necessary (probably everywhere as there are no example that I can think of which actually uses characters).
This goes along the line that I remember @tfry-git saying about defining more closely the types we are working with.

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

1 participant