HiI was trying to create a sketch in my eclipse environment in Arduino 1.0 using the wire library.The compilation failed. Investigation pointed out that my eclipse plugin compiles all files as C++ files where the Arduino IDE has the compiler select the C or C++mode.As a consequence of this twi.c is compiled as C code and wire.cpp is compiled as C++ code in the Arduino IDE. In my plugin they are both compiled as C++.wire.cpp includes twi.h as follows:

#include "twi.h"As a consequence twi.h is always compiled as C in the arduino IDE. However in the eclipse plugin it is compiled as C in wire.cpp an as C++ in twi.c.I accept this can not be called a bug but I feel it would be nicer to change twi.h so that there is encapsulation of twi.h. (no need for extern "C" in wire.cpp). twi.h would look as follows:

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA*/

As a consequence of this twi.c is compiled as C code and wire.cpp is compiled as C++ code in the Arduino IDE. In my plugin they are both compiled as C++.

I think that makes your plugin broken. Probably in easily fixable ways. I don't think there's a reason to change .c files in the arduino distribution so that they compile even when treated as c++, even if that's possible.

ManiacbugThanks for the link to the "open issue". I created one for this.I agree it doesn't make much sense from an Arduino IDE point of view. It is however hardly any work (I included the better twi.h) and results in better code quality.

best regardsJantje

PS I've found a way around it.

Do not PM me a question unless you are prepared to pay for consultancy.Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -

ChrisThe consequences are only visible for people writing their own tools on top of the Arduino library.Basically you can not compile twi.c with the C++ compiler.Further on I think it is a matter of taste on whether you prefer self containment and robustness or strict language layering (C code should not know about C++). Probably other arguments exist as well for both options.Technically it is about the fact that C++ does name mangling and C does not. See http://en.wikipedia.org/wiki/Name_mangling for more info on name mangling.

You can easily find the ticked by following the create ticked link and searching for Wire.h

Best regardsJantje

Do not PM me a question unless you are prepared to pay for consultancy.Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -