Skip to content

Definition of INADDR_NONE in header file bloats final executable size #128

Closed
@MHotchin

Description

@MHotchin

Currently, IPADDRESS.H both declares and defines INADDR_NONE.

If a sketch has more than one file that includes IPAddress.h, then multiple copies of INADDR_NONE end up in the final executable. Essentially, each CPP file gets its own copy as a global variable, at 6 bytes a pop.

If the declaration in IPAddress.h is changed to:
extern const IPAddress INADDR_NONE;

and a new definition is provided in IPAddress.cpp:
const IPAddress INADDR_NONE(0, 0, 0, 0);

then only one copy end up in the executable.

My sketch went from 2002 bytes 'Minimum Memory Usage' to 1888 bytes, a savings of 78 bytes in my case.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions