stannickel / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Sketch .c, .cpp, and .h files not searched for library includes. #636

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create sketch with additional .h/.cpp files (class)
2. In the .cpp include an Arduino library
   Do not include said library in the main sketch file
3. Build the sketch

What is the expected output? What do you see instead?
Expected: The sketch should build.
Result: Build error due to missing include directories

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
Arduino 0022 on Arch Linux with a variety of boards

Please provide any additional information below.
Adding the same library to the main file resolves this issue since then the 
scrips include the neccessary include directores in the build process.

It seems to me that the build script should add the include directories needed 
even if I don't include them in the main file, or at least give me and option 
of specifying include directories manually.

Original issue reported on code.google.com by robert.a...@gmail.com on 9 Sep 2011 at 3:36

GoogleCodeExporter commented 9 years ago
Thanks for the report.  The library search functionality is definitely a bit 
wonky and could use some rethinking / cleanup.

Original comment by dmel...@gmail.com on 9 Sep 2011 at 7:21

GoogleCodeExporter commented 9 years ago
This issue also occurs in rc1.  The workaround is to also include the library 
in the main sketch file.

Original comment by de...@peerassembly.com on 5 Oct 2011 at 11:56

GoogleCodeExporter commented 9 years ago
Another problematic scenario: I have an "RTClib" which supports real-time clock 
functionality through various means (millis, h/w I2C, s/w I2C, DCF77). The most 
commonly used option is not h/w I2C, but since RTClib includes code which needs 
the Wire library, everyone gets an error if they don't include "Wire.h" in 
their main sketch. The lack of automatic linker dependency checking forces 
everyone to manually do it.

Linking with all libraries to let the linker resolve all references is probably 
impossible due to name conflicts.

There *is* a solution, which is to use C++ namespaces. It's going to require 
some extra effort by all library makers, and some explanation for newbies ("use 
FancyLibName::MYCONST instead of MYCONST"). To make this work, the Arduino team 
will need to take the lead and set the example. See issue #651 for a related 
name conflict.

Original comment by jc@wippler.nl on 15 Oct 2011 at 9:25