Timeline for Including libraries from header files sometimes doesn't work
Current License: CC BY-SA 3.0
10 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Aug 30, 2015 at 20:39 | comment | added | Igor Stoppa | @NickGammon: the build process is still a mess as it does (black) magic with headers and I consider it as an encouragement to people doing even more evil things with headers. | |
| Aug 30, 2015 at 20:34 | comment | added | Nick Gammon♦ | @IgorStoppa - yes it is intended for newbies, and you must surely admit that Make is not for the faint-hearted. The process is described in a reply I made. I note that Ariser now says that the library is a mess, which presumably lets the build process of the hook a bit. The IDE can't help it if people put all their functions into .h files. | |
| Aug 30, 2015 at 18:13 | comment | added | Igor Stoppa | @Ariser: you could have a look at this: instructables.com/id/How-to-get-started-with-Eclipse-and-AVR/… I'm not too fond of Eclipse, but it beats to a pulp the Arduino IDE hands down any day. And if you have an AVR Dragon, you can also ditch the serial prints and debug like it's supposed to be done on embedded devices: larsen-b.com/Article/315.html | |
| Aug 30, 2015 at 18:06 | comment | added | Igor Stoppa | @NickGammon: More like passing to a real build process. The Arduino builds stuff in a way that is meant to help newbies, but it's disconcerting, to say the least, to those who are used to more traditional Unix ways of building code. Make, to mention one. | |
| Aug 30, 2015 at 0:31 | comment | added | Ariser | @Majenko I'm familiar with separation of declaration and definition. But I didn't suspect that this library was broken. I should have been alerted by the fact, that it was i linker and not a compiler error. Looking closely, this library lacks a source file completely. What a mess, I'm going to rewrite it... | |
| Aug 29, 2015 at 22:52 | comment | added | Nick Gammon♦ | Sigh. I guess time to move to a "real" IDE!? - you would have that problem anywhere. As Majenko said, .h files are for declarations. To define something it should be done once, in a .c or .cpp file. You won't get double definitions on the class declaration. Your PinChangeInt library should also have a PinChangeInt.cpp file which is compiled once. | |
| Aug 29, 2015 at 22:43 | comment | added | Majenko | @Ariser Include guards only work within the same compilation unit. If you include the file in separate cpp or ino files it will exist multiple times, and any variables or functions defined in there will be conflicting. You should never have functions or variables in headers - put them (once) in cpp or ino files and put extern references to them in the header files. The header files then act like a "sharing" point for the variables and functions in the other cpp and ino files. | |
| Aug 29, 2015 at 22:20 | comment | added | Ariser | Thanks a lot. In the past I fiddled cluelessly around until it finally somehow worked out. After adding all libs to my INO header file, all libraries are detected, but I have a new problem. The IDE somehow managed to circumvent the include guard definition of PinChangeInt.h (custom library, which I tested already successfully). Linker is now complaining about lots of double definitions. Sigh. I guess time to move to a "real" IDE!? | |
| Aug 29, 2015 at 22:13 | vote | accept | Ariser | ||
| Aug 29, 2015 at 21:58 | history | answered | Majenko | CC BY-SA 3.0 |