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

Compiler warnings not shown on subsequent compilations #1008

Open
3 tasks done
rkost opened this issue Oct 15, 2016 · 3 comments
Open
3 tasks done

Compiler warnings not shown on subsequent compilations #1008

rkost opened this issue Oct 15, 2016 · 3 comments
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement type: imperfection Perceived defect in any part of project

Comments

@rkost
Copy link

rkost commented Oct 15, 2016

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
@matthijskooijman
Copy link
Collaborator

This is caused by caching: the second time the file is not recompiled if it was unchanged, so the warnings are not shown. The only way I can see to fix this (other than making warnings into errors), is to cache the stdout/stderr output as well, so it can be shown again even when not running the compiler. Not sure if this is the best way to approach this, though.

@facchinm
Copy link
Member

@matthijskooijman is correct, caching elides warnings from previous compilations. I believe that ccache caches stdout/stderr and replays them even if the cached version is unchanged, so the approach could be ok, we only need to find a suitable "backend" for storing this information (taking care it also works in a cloud infrastructure)

@per1234 per1234 transferred this issue from arduino/Arduino Oct 5, 2020
@per1234 per1234 reopened this Mar 30, 2021
@per1234
Copy link
Contributor

per1234 commented Jun 19, 2021

There is some valuable related discussion here: arduino/arduino-builder#301

Matthijs was kind enough to add a link to here on that end, but it seems the backtrack reference generated by GitHub was lost when I transferred this issue from the arduino/Arduino repo.

@fstasi fstasi removed the type: bug label Sep 16, 2021
@rsora rsora added type: imperfection Perceived defect in any part of project topic: core labels Sep 22, 2021
@per1234 per1234 added the topic: code Related to content of the project itself label Jan 31, 2023
@per1234 per1234 changed the title Compiler warnings not shown if compilation was done a second time Compiler warnings not shown on subsequent compilations Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: enhancement Proposed improvement type: imperfection Perceived defect in any part of project
Projects
None yet
Development

No branches or pull requests

7 participants