Skip to main content
7 events
when toggle format what by license comment
Sep 27, 2022 at 9:01 review Suggested edits
Sep 27, 2022 at 15:18
May 23, 2017 at 10:16 comment added frarugi87 Yes, I agree that the global variables should be put in the first file so that everyone can access it. Or make a class... This was just the most classical solution (C/C++ compilers do not append source files)
May 23, 2017 at 10:14 comment added frarugi87 I think that the extern should be "ignored" (in fact you usually use the extern in the header file which is then included also in the c file defining it)
May 23, 2017 at 10:14 comment added Majenko It compiles, so yes you can do that, but why exactly would you, when you are then effectively defining it in both files anyway? Just define it in the first. If you want to make something portable between sketches then make it a library.
May 23, 2017 at 10:11 comment added Majenko Not sure. It may complain about multiple definitions of the same symbol, but may not. I'll test it.
May 23, 2017 at 10:10 comment added frarugi87 What happens if you try to do what a C programmer should do? I mean, in one of the source (e.g. .ino) files you define the variable int a;, then in the other you declare it again with extern int a;. Will this work if 1) the variable is defined in the main ino and 2) if it is defined somewhere else but is declared in the main? I do not have the IDE installed here to test it myself ;)
May 23, 2017 at 9:57 history answered Majenko CC BY-SA 3.0