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

Move "core_pins.h" include from source to header file #762

Closed
wants to merge 2 commits into from

Conversation

forderud
Copy link

@forderud forderud commented Sep 23, 2024

Fixes the following errors if attempting to compile usb_serial.h as C++ code:

usb_serial.h:93:25: error: 'yield' was not declared in this scope
usb_serial.h:177:45: error: 'millis' was not declared in this scope

Fixes the following errors if attempting to compile usb_seremu.h as C++ code:

usb_seremu.h:68:41: error: 'systick_millis_count' was not declared in this scope
usb_seremu.h:79:25: error: 'yield' was not declared in this scope
usb_seremu.h:102:27: error: 'yield' was not declared in this scope

I can also update the teensy and teensy3 implementation the same way if desired.

Motivation

I want to improve compatibility with C++11 (and newer), so that I can eventually use constexpr in USB-related code.

@PaulStoffregen
Copy link
Owner

Unlikely to merge this.

@forderud
Copy link
Author

Unlikely to merge this.

Why?

The usb_serial.h header contain yield() and millis() calls within the C++ usb_serial_class class. These calls triggers a compiler error if "core_pins.h" is not included first. I'm just trying to get exiting code to compile also with a C++ compiler.

Done to fix the following errors if attempting to compile usb_serial.h as C++ code:
usb_serial.h:93:25: error: 'yield' was not declared in this scope
usb_serial.h:177:45: error: 'millis' was not declared in this scope
Done to fix the following errors if attempting to compile usb_seremu.h as C++ code:
usb_seremu.h:68:41: error: 'systick_millis_count' was not declared in this scope
usb_seremu.h:79:25: error: 'yield' was not declared in this scope
usb_seremu.h:102:27: error: 'yield' was not declared in this scope
@PaulStoffregen
Copy link
Owner

Changing which headers include others needs to be explained with very solid reasoning. Without very strong reason, I'm not going to merge this sort of change.

@PaulStoffregen
Copy link
Owner

Please do not send this sort of pull request without very clearly explained reason why. Extensive testing is needed to verify the change does not break programs and libraries.

I've been burned before by this sort of change. The Arduino ecosystem is a mostly unplanned growth of many libraries where small changes in header includes can have unintended consequences.

So to repeat again, very unlikely to accept this sort of change which alters which headers include other headers.

@forderud
Copy link
Author

forderud commented Oct 5, 2024

Apologies if my PRs feels like a burden @PaulStoffregen. That was not my intent. My intent is only to be a good citizen by contributing small fixes and code improvements back to the project, so that others can also benefit from them. This sort of behavior is often appreciated by open-source project maintainers.

Please do not send this sort of pull request without very clearly explained reason why. Extensive testing is needed to verify the change does not break programs and libraries.

The PR already explains precisely which compiler errors are fixed by this PR. You can reproduce the errors by including either usb_seremu.h or usb_serial.h from a .cpp source as done in #763. The motivation for doing so in the first place was that I wanted to avoid having to manually keep NUM_INTERFACE in sync when experimenting with different USB configurations as proposed in #766. I've split my changes into small PRs with what I thought was clear reasoning to ease code review and reduce risk of accidental regressions.

I'll be listening and do my best to accommodate your feedback if you give feedback on desired code modifications or want me to perform specific testing steps.

I've been burned before by this sort of change. The Arduino ecosystem is a mostly unplanned growth of many libraries where small changes in header includes can have unintended consequences.

So to repeat again, very unlikely to accept this sort of change which alters which headers include other headers.

Again, I'm sorry if my PRs feel like a burden. My motivation has been to help the project by contributing changes back instead of just being a passive consumer.

I'll of course stop submitting new PRs and instead put them in my own fork moving forward if you're not interested in my contributions.

@PaulStoffregen
Copy link
Owner

PaulStoffregen commented Oct 5, 2024

I am interested in most of your edits. But I want to urge you to NOT change which headers include other headers. Please, just resist the temptation, as that sort of editing absolutely will diverge your fork.

@forderud
Copy link
Author

forderud commented Oct 7, 2024

I am interested in most of your edits. But I want to urge you to NOT change which headers include other headers. Please, just resist the temptation, as that sort of editing absolutely will diverge your fork.

Understood.

I've now submitted #767 that attempts to solve the same C++ compatibility problem by instead reordering "core_pins.h" includes in two source files. This avoid changing which headers include other headers by instead changing the source files that include the headers.

@forderud forderud closed this Oct 7, 2024
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