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

allow disabling global Serial and Serial1 object #2807

Merged
merged 2 commits into from
Dec 29, 2017
Merged

allow disabling global Serial and Serial1 object #2807

merged 2 commits into from
Dec 29, 2017

Conversation

Palatis
Copy link
Contributor

@Palatis Palatis commented Dec 28, 2016

allow the user to disable specific global Serial objects to save
memory.

that's 0x1c bytes per object.

allow the user to disable specific global `Serial` objects to save
memory.

that's 0x1c bytes per object.
@codecov-io
Copy link

codecov-io commented Dec 28, 2016

Codecov Report

❗ No coverage uploaded for pull request base (master@2880354). Click here to learn what that means.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #2807   +/-   ##
========================================
  Coverage          ?   27.8%           
========================================
  Files             ?      20           
  Lines             ?    3625           
  Branches          ?     656           
========================================
  Hits              ?    1008           
  Misses            ?    2441           
  Partials          ?     176

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2880354...7b8edb3. Read the comment docs.

@igrr
Copy link
Member

igrr commented Jan 5, 2017

I think the "arduino" way of doing this is to move each object's definition into a separate cpp file. Then the objects which aren't used anywhere will not be linked into the output file. I don't particularly mind the approach taken in this MR though...

@Palatis
Copy link
Contributor Author

Palatis commented Jan 7, 2017

I took this approach because others does, too.

Such as SSDP and MDNS...

@devyte devyte merged commit 2b868aa into esp8266:master Dec 29, 2017
@romansavrulin
Copy link

@igrr @Palatis Where should I put NO_GLOBAL_INSTANCES define get benefit from that? Main sketch file?

@Palatis
Copy link
Contributor Author

Palatis commented Feb 15, 2018

in platformio.ini, build_flags = -DNO_GLOBAL_INSTANCES

@romansavrulin
Copy link

@Palatis thank you, that way is expected. I thought there's some "Arduino Way of doing this"

@Palatis
Copy link
Contributor Author

Palatis commented Feb 16, 2018

"the Arduino way of doing this" is leave them there and hope they get stripped by the linker...

i guess...

@d-a-v
Copy link
Collaborator

d-a-v commented Feb 16, 2018

It can't be stripped since it is a global variable with a constructor.
You can put this in a new file platform.local.txt:

compiler.c.extra_flags=-DNO_GLOBAL_INSTANCES
compiler.cpp.extra_flags=-DNO_GLOBAL_INSTANCES

(next to platform.txt)

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.

6 participants