Skip to content

Refactor for C++11 and Teensy 4.1 - #14

Open
natehouk wants to merge 1 commit into
rotenbergrr:masterfrom
natehouk:master
Open

Refactor for C++11 and Teensy 4.1#14
natehouk wants to merge 1 commit into
rotenbergrr:masterfrom
natehouk:master

Conversation

@natehouk

@natehouk natehouk commented Jun 27, 2023

Copy link
Copy Markdown

Changes required to compile with C++11 (as of version 1.6.6, the Arduino IDE enables C++11 by default) on a Teensy 4.1 board.

@rotenbergrr rotenbergrr left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi! 👋
thanks for contributing to Midier 🤩

asked you a few qs in the notes.
also, I think that Midier already uses C++11
are you sure the changes you did are required for using the new Arduino IDE?

Comment thread src/note/note.h
};

enum class Accidental : char
enum class Accidental : short

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

char is 1 byte and short is 2 bytes right?
so we increase the memory footprint with this change am I right?
if so, any chance to keep it a single byte?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to find a signed byte type for Teensy 4.1 so short was the smallest type I could find that can hold negative numbers.

Comment thread src/sequencer/sequencer.h
};

enum class Bar : char
enum Bar : short

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here re the char vs short
also, why not using enum class anymore?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't able to find a signed byte type for Teensy 4.1 so short was the smallest type I could find that can hold negative numbers.

The class was removed as enum class won't compile:

In file included from /Users/natehouk/Documents/Arduino/libraries/Midier/src/sequencer/sequencer.cpp:1:
/Users/natehouk/Documents/Arduino/libraries/Midier/src/sequencer/sequencer.h:18:10: warning: elaborated-type-specifier for a scoped enum must not use the 'class' keyword
   18 |     enum class Bar : int8_t
      |     ~~~~ ^~~~~
      |          -----

const auto mspc = mspb / (float)midier::Time::Subdivisions; // ms per click

if (_clicked == -1)
if (_clicked == ULLONG_MAX)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we initialize _clicked to -1 explicitly, so why not checking against this value as well?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because _clicked is a unsigned long long and therefore can't be compared to -1 without throwing a warning. This is to remove the warning.

@natehouk natehouk changed the title Refactor for C++11 Refactor for C++11 and Teensy 4.1 Jun 27, 2023
@natehouk

Copy link
Copy Markdown
Author

I edited my pull request title to clarify that these changes were required to get it to compile on a Teensy 4.1 board.

@natehouk natehouk mentioned this pull request Jun 27, 2023
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