Pages: [1]   Go Down
Author Topic: More Arduino 1.0 issues  (Read 2877 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm now trying to port the gaikl ArduinoEthernet libraries to 1.0 RC 2.

I'm using Pauls tip:

#if ARDUINO >= 100
  #include "Arduino.h"
#else
   #include "WProgram.h"
#endif

But I still get a lot of errors. It seems to be they changed more than just renaming WProgram.h to Arduino.h and "Renamed Ethernet Client, Server, and UDP classes to EthernetClient, EthernetServer, and EthernetUDP."

Any leads on this?!

I changed:
   #include "wiring.h"
to

#if ARDUINO >= 100
  #include "Arduino.h"
#else
   #include "wiring.h"
#endif

as discussed here:
http://code.google.com/p/arduino/issues/detail?id=682

But other header files like
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>

seem to be redundant now so I also made those conditional.

E.g. Paul can you elaborate on that?! I can't find the reason for these errors other than that Arduino.h is redeclaring stuff that is already declared using the mentioned header files.

Most of the time errors are of this form:

In file included from /Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:191,
                 from /Applications/Arduino.app/Contents/Resources/Java/libraries/EthernetBonjour/EthernetBonjour.cpp:29:
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:116: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, const char*)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:115: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const String&)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:117: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, char)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:116: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, const char*)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:118: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:117: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, char)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:119: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:118: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned char)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:120: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:119: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, int)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:121: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:120: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, unsigned int)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:122: error: declaration of C function 'StringSumHelper& operator+(const StringSumHelper&, long unsigned int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:121: error: previous declaration 'StringSumHelper& operator+(const StringSumHelper&, long int)' here
In file included from /Applications/Arduino.app/Contents/Resources/Java/libraries/EthernetBonjour/EthernetBonjour.cpp:29:
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:195: error: declaration of C function 'uint16_t makeWord(byte, byte)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:194: error: previous declaration 'uint16_t makeWord(uint16_t)' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:205: error: declaration of C function 'long int random(long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/include/stdlib.h:504: error: previous declaration 'long int random()' here
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:206: error: declaration of C function 'long int random(long int, long int)' conflicts with
/Applications/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Arduino.h:205: error: previous declaration 'long int random(long int)' here

Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

you cannot conditionally include header files with Arduino

regex is used to scan sketches for #include, but the scanning technique does not care about #if or #ifdef, see https://github.com/arduino/Arduino/blob/master/app/src/processing/app/preproc/PdePreprocessor.java to understand how this is done

I think one work around is to use "# include" instead of "#include", which would confuse the regex
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ooh really, but why then are people like Paul Stoffregen advising me to do it like that?!

http://arduino.cc/forum/index.php/topic,78985.0.html

That actually works.

And a lot of other excellent working libraries use the same construction. So either I don't get you or something else!?!

B.t.w. I removed the conditional stuff to no avail, same errors.
« Last Edit: November 20, 2011, 04:12:16 am by jopiek » Logged

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

what I said only applies to sketches, not libraries, the IDE does not scan your library using the same regex
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ha that makes sense!!! I will remember that.

But... I mainly used in (now only use it) in Libraries, so that is not the problem I think (although it was very useful to remember this).
« Last Edit: November 20, 2011, 04:23:24 am by jopiek » Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 75
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I solved the compile errors for EthernetBonjour.cpp by placing #include "Arduino.h" below the other includes:


//  Copyright (C) 2010 Georg Kaindl
//  http://gkaindl.com
//
//  This file is part of Arduino EthernetBonjour.
//
//  EthernetBonjour 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 3 of
//  the License, or (at your option) any later version.
//
//  EthernetBonjour 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 EthernetBonjour. If not, see
//  <http://www.gnu.org/licenses/>.
//

#define  HAS_SERVICE_REGISTRATION      1  // disabling saves about 1.25 kilobytes
#define  HAS_NAME_BROWSING             1  // disable together with above, additionally saves about 4.3 kilobytes

#include <string.h>
#include <stdlib.h>

extern "C" {
   #include <utility/EthernetUtil.h>
}

#include <utility/EthernetCompat.h>
#include "EthernetBonjour.h"
#include "Arduino.h"

// then the rest of the 'old' code...
Logged

0
Offline Offline
God Member
*****
Karma: 26
Posts: 606
Always making something...
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Maybe there's something not quite right about the 1.0-rc2 headers, since it works if you include them in one order, but not in another?

If you send me the code which produces all those errors, I'll investigate.  Please email me directly, paul at pjrc dot com.

Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Was also using George Kaindls DHCP library and can no longer compile and just found this thread.  Did anyone find a solution ormanage to port the lib to Arduino 1.0?

Any help much appreciated!
Logged

Pages: [1]   Go Up
Jump to: