Skip to content

Document handling of editor "tabs" / concatenation of multiple sketch files #372

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

Open
varnonga opened this issue Jun 12, 2019 · 11 comments
Open
Labels
community Bugs and fixes suggested by the community enhancement New feature or request

Comments

@varnonga
Copy link

I have a bug in the Arduino software version 1.8.9. Initially, I wrote my code to have several tabs each with some categorized functions. At first everything compiled well and there were no errors. Programs loaded into my Arduino 2560 and functioned. I made a few tweaks in my code to have some data display on a serial port LCD I had. Things were going well then, suddenly, my code stopped working. I got compile errors for some of my functions not being declared.

In order to get passed these compile errors, I had to add include statements for each tab that contained my functions. I am not sure why this happened. In one of my tabs, I had a function that called a different function under a different tab. I tried adding an #include statement for that tab in that function. I got an error about a "function definition is not allowed here before a {". Things are really weird right now, and I don't know why.

I have an HP8570 with Windows 7 with service pack 2 installed.

@per1234
Copy link
Contributor

per1234 commented Jun 12, 2019

Hi @varnonga. In order for us to investigate this issue, we need to be able to reproduce it. You haven't provided enough information for us to do that. What we really need is a minimal, complete, verifiable example. This would be a complete sketch with only the minimum amount of code necessary to demonstrate the bug, and no extra unnecessary code.

@PaulStoffregen
Copy link

This is very likely a mistake in your code. The forum is probably a better place to ask. But it may be a bug in the Arduino software... which is what this issue tracker is about.

Either way, nobody can say without seeing the complete code you used.

@varnonga
Copy link
Author

varnonga commented Jun 12, 2019 via email

@varnonga
Copy link
Author

varnonga commented Jun 12, 2019 via email

@matthijskooijman
Copy link

Your code does not seem to contain any functions, only constants. Perhaps your code was cut short? Also, I can't tell from your code where one file starts and the next one ends. It might be better to put your files on gist.github.com, or perhaps upload them as a zip for easy reproduction. Also be sure to include the actual error message you're getting from the IDE.

@varnonga
Copy link
Author

varnonga commented Jun 12, 2019 via email

@per1234
Copy link
Contributor

per1234 commented Jun 12, 2019

There is nothing in the documentation that really talks about the relationship between “ino” files and the “rules of engagement”. It might be nice to have an article on this somewhere.

Here's the documentation on how multiple .ino files work:
https://github.com/arduino/Arduino/wiki/Build-Process#pre-processing

All .ino files in the sketch folder (shown in the IDE as tabs with no extension) are concatenated together, starting with the file that matches the folder name followed by the others in alphabetical order

I'm not sure that information is very prominently available for a novice wondering how multiple .ino files are handled in a sketch. The path to it from arduino.cc is Resources > Tutorials > Hacking > Build Process. I wonder if it would make sense to also provide this information on the more obvious and prominent "Arduino Software (IDE)" page's "Tabs, Multiple Files, and Compilation" section, which currently seems quite light on information:
https://www.arduino.cc/en/Guide/Environment#toc8

@PaulStoffregen
Copy link

I have no idea what these words mean:

or two “ino” files call the same “ino” files

Files don't "call" other files. They can "include" other files. But the code you showed has includes only for Arduino.h.

Maybe you should find the location where Arduino is saving the files and make a ZIP archive of the folder and all the files it contains. Then you can upload that ZIP file (perhaps a "gist" or on a file sharing site like bitbucket) so we can look at the actual files.

Also, if you ask this question on the forum (where it is almost certainly more appropriate) you will also need to clearly show all the files. By withholding any of the files, you're making it impossible to figure out what's really wrong. That only wastes everyone's time and hinders helping you and figuring out whether there is really any defect in the Arduino software that needs fixing.

@varnonga
Copy link
Author

varnonga commented Jun 13, 2019 via email

@per1234
Copy link
Contributor

per1234 commented Jun 13, 2019

Maybe put something under “Reference”.

This would be done as part of my first proposed solution to arduino/reference-en#623
That is only a side effect of that proposal though. I don't think the Language Reference is the obvious place for someone wondering how multiple .ino tabs are handled to look.

I still think the more logical place for people using the Arduino IDE to look for information on how multiple .ino tabs are handled would be in the https://www.arduino.cc/en/Guide/Environment#toc8. However, I hadn't previously considered that users of Arduino Web Editor and arduino-cli probably don't expect to find anything of relevance in that page.

@per1234 per1234 changed the title "#include" required for ino files Document handling of editor "tabs" / concatenation of multiple sketch files Sep 29, 2020
@per1234
Copy link
Contributor

per1234 commented Oct 1, 2020

I'm not sure that information is very prominently available for a novice wondering how multiple .ino files are handled in a sketch. The path to it from arduino.cc is Resources > Tutorials > Hacking > Build Process. I wonder if it would make sense to also provide this information on the more obvious and prominent "Arduino Software (IDE)" page's "Tabs, Multiple Files, and Compilation" section,

This part of the issue has now been resolved:
https://www.arduino.cc/en/Guide/Environment#tabs-multiple-files-and-compilation

However, the issue remains that the "Environment" documentation page is specific to the Arduino IDE, so users of other official Arduino development software will likely not think to look there. So I'll leave this open.

I'm not sure that information is very prominently available for a novice wondering how multiple .ino files are handled in a sketch. The path to it from arduino.cc is Resources > Tutorials > Hacking > Build Process.

There is now an even longer journey to travel before finding the information via that path:
Documentation > Tutorials > Hacking > Build Process > content moved to https://github.com/arduino/Arduino/wiki/Build-Process > content moved to https://arduino.github.io/arduino-cli/sketch-build-process/ > Pre-Processing

@per1234 per1234 transferred this issue from arduino/Arduino Jul 17, 2022
@per1234 per1234 added enhancement New feature or request community Bugs and fixes suggested by the community labels Jul 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
community Bugs and fixes suggested by the community enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants