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

Case difference in the sketch folder and file name causes the IDE to try to compile the wrong file #8030

Open
notisrac opened this issue Sep 25, 2018 · 1 comment · May be fixed by #11554
Open
Labels
Component: IDE The Arduino IDE OS: Windows Specific to the Windows version of the Arduino IDE Type: Bug

Comments

@notisrac
Copy link

notisrac commented Sep 25, 2018

Bear with me on this one, as it is a bit complicated to explain :) Also, sorry if this is a dupe - I tried searching, but found nothing.

The scenario:

  • OS is Windows
  • You have a sketch folder named "Test"
  • You have an .ino file and at least one .h file in that folder (Named test.ino and a.h)
  • (The sketch file includes the .h file)
  • In an alphabetical order, the .h file's name is ahead the .ino file's name
  • The case of the first letter of the .ino file's name does not match the case of the sketch folder's name's first letter (The other letters don't matter)

The bug:
When you load this sketch into the IDE, the .h file will come before the .ino file in the tab list! This will result in the IDE treating the .h file as the main program code, and will pass that to the compiler.

Example:
Sketch folder structure:
C:\Test\test.ino
C:\Test\a.h

Note the following:

  • The name of the sketch folder and the .ino file differs in the case of the letter 'T' only!
  • The name of the header file 'a' is before the letter 't' in the alphabetical order
  • It will also work with the following: C:\tEST\Test.ino

test.ino:

// test
#include "a.h"	

void setup() {
  uint8_t x = imaNumber;
}

void loop() {
}

a.h:

#ifndef TEST_H
#define TEST_H

uint8_t imaNumber = 5;

#endif // TEST_H

image

When trying to build this, the IDE will present you with an error message: test:2:16: error: a.h: No such file or directory

Further analysis of the output panel reveals the cause of the error message:

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs ... (snip) ... -verbose C:\Test\a.h
C:\Program Files (x86)\Arduino\arduino-builder -compile ... (snip) ... -verbose C:\Test\a.h
...
"C:\\Program Files (x86)\\Arduino\\hardware\\tools\\avr/bin/avr-g++" -c ... (snip) ... "C:\\Users\\me\\AppData\\Local\\Temp\\arduino_build_814342\\sketch\\a.h.cpp" -o nul

Note, that both of the arduino-builder executions get the a.h as the file to be built, just like avr-g++ gets a.h.cpp.

This does not happen in any other case, than this! (Try renaming a.h to z.h)

Tested with v1.8.6, v1.8.7, v1.8.7 Hourly Build 2018/09/20 02:27, 1.8.14 Hourly Build 2021/03/09 09:33

So there are two questions I have regarding this issue:

  1. Why is there a difference between the upper and lower case names - and why only the first character?
  2. Why does the IDE use the first file in the tab list as the main code file?

Again, sorry if this is a duplicate.

@facchinm facchinm added Component: IDE The Arduino IDE Type: Bug OS: Windows Specific to the Windows version of the Arduino IDE labels Sep 26, 2018
@facchinm
Copy link
Member

Hi @notisrac , thanks for reporting. This is clearly a problem with case-sensitiveness so it should "only" affect Windows and OSX with case insensitive filesystems. I think the IDE should complain if there's no perfect match between main .ino and the containing folder. @cmaglie what do you think about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: IDE The Arduino IDE OS: Windows Specific to the Windows version of the Arduino IDE Type: Bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants