Skip to content

Conditional library include statements incorrectly cause that library to be linked in. #4126

@SlashDevin

Description

@SlashDevin

Consider this simplified example:

#if 0
  #include <NeoHWSerial.h>
#endif

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

void loop() {}

This forces the NeoHWSerial library to be linked in, even when the condition is FALSE and there are no compile-time references to that library.

As a result, ISRs in HardwareSerial (via 'Serial') conflict with the same ISRs in the incorrectly linked-in NeoHWSerial. Simply commenting out the NeoHWSerial include statement removes the "require" of that library, and HardwareSerial links in correctly, as the only source of the ISRs:

#if 0
  //#include <NeoHWSerial.h>
#endif

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

void loop() {}

I found this on 1.0.5 and reproduced it on 1.6.5r2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions