Skip to content

Compiler warnings not shown on subsequent compilations #1008

Open
@rkost

Description

@rkost

Describe the problem

Compiler warnings for code from non-.ino source files are not shown on subsequent sketch compilations.

To reproduce

When someone writes code like this (see below) he will correctly get two identical warnings:

warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]

When one compiles it again the warnings will all disappear so the user (me) thinks he is perfectly fine and writing clean code.

FunFact: This will not happen if all code is written to the main (.ino) file.

File DummyClass.h:

class DummyClass
{
public:
  char* getString();

  char* getSecondString();
};

File DummyClass.cpp:

char* DummyClass::getString()
{
  return "Some String";
}

char* DummyClass::getSecondString()
{
  return "Some other string";
}

File test.ino:

#include "DummyClass.h"
DummyClass dummy;

void setup()
{
  Serial.begin(115200);
}
void loop()
{
  Serial.println(dummy.getString());
  delay(1000);
}

Expected behavior

Compiler warnings are shown every time the sketch is compiled if the code would produce a warning.

Arduino CLI version

60a8aa9

Operating system

All

Operating system version

Any

Additional context

Additional reports

Related

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: codeRelated to content of the project itselftype: enhancementProposed improvementtype: imperfectionPerceived defect in any part of project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions