Skip to content

Conversation

@matthijskooijman
Copy link
Collaborator

These functions do not modify the IPAddress object, but were not marked
as const. This meant that you could not do:

void set_ip(const IPAddress& ip) {
this->ip = ip;
}

Since calling operator uint32_t() on ip would discard the constness of
the reference.

@cmaglie
Copy link
Member

cmaglie commented Jan 15, 2014

Applying const to methods is good, but for some reason it breaks the AdvancedChatExample, may you check that?

May you also apply the patch to the SAM core?

@matthijskooijman
Copy link
Collaborator Author

What example do you mean exactly? I tried the AdvancedChatServer example, which compiles normally (though it seems to use too much memory when for the Arduino Ethernet, but that's also without my patch applied).

What board are you using? What error are you seeing?

@cmaglie
Copy link
Member

cmaglie commented Jan 15, 2014

Yes the example is AdvancedChatServer, I'm compiling for Arduino Uno, it gives:

Arduino: 0155 (Linux), Board: "Arduino Uno"

Using library SPI in folder: /home/megabug/git/arduino/build/linux/work/hardware/arduino/avr/libraries/SPI (legacy)
Using library Ethernet in folder: /home/megabug/git/arduino/build/linux/work/libraries/Ethernet 

[...cut...]

/home/megabug/git/arduino/build/linux/work/hardware/tools/avr/bin/avr-g++ -c -g -Os -w -fno-exceptions -ffunction-sections -fdata-sections -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=155 -DARDUINO_AVR_UNO -DARDUINO_ARCH_AVR -I/home/megabug/git/arduino/build/linux/work/hardware/arduino/avr/cores/arduino -I/home/megabug/git/arduino/build/linux/work/hardware/arduino/avr/variants/standard /home/megabug/git/arduino/build/linux/work/hardware/arduino/avr/cores/arduino/IPAddress.cpp -o /tmp/build4145119589917473324.tmp/IPAddress.cpp.o 
/home/megabug/git/arduino/build/linux/work/hardware/arduino/avr/cores/arduino/IPAddress.cpp:40: error: prototype for ‘bool IPAddress::operator==(const uint8_t*)’ does not match any in class ‘IPAddress’
/home/megabug/git/arduino/build/linux/work/hardware/arduino/avr/cores/arduino/IPAddress.h:54: error: candidates are: bool IPAddress::operator==(const uint8_t*) const
/home/megabug/git/arduino/build/linux/work/hardware/arduino/avr/cores/arduino/IPAddress.h:53: error:                 bool IPAddress::operator==(const IPAddress&) const

Maybe you should add the "const" on the operator== implementation in IPAddress.cpp

@matthijskooijman
Copy link
Collaborator Author

Yeah I should, I'm almost certain that's the problem.

I also realized why I couldn't reproduce it: The build/linux/work/hardware directory still had the core files from the last time I ran "ant", I didn't realize that I did a "regular" build that copies those files instead of symlinks a while ago.

I'll push an updated patch with both things fixed in a minute, thanks for having a look.

These functions do not modify the IPAddress object, but were not marked
as const. This meant that you could not do:

void set_ip(const IPAddress& ip) {
	uint32_t copy = ip;
}

Since calling operator uint32_t() on ip would discard the constness of
the reference.
@matthijskooijman
Copy link
Collaborator Author

Here's the update. Also tested the AdvancedChatServer example for the Due.

@cmaglie cmaglie merged commit dde1a75 into arduino:ide-1.5.x Jan 16, 2014
@matthijskooijman matthijskooijman deleted the ide-1.5.x-ipaddress-const branch February 14, 2014 09:35
matthijskooijman added a commit to Pinoccio/library-gainspan-s2w that referenced this pull request Mar 24, 2014
arduino/Arduino#1798 was merged, so this is no
longer needed. This means that this code will only work with a recent
nightly build, the Arduino 1.5.6 release does not have this fix yet.
matthijskooijman added a commit to Pinoccio/library-gainspan-s2w that referenced this pull request Mar 26, 2014
arduino/Arduino#1798 was merged, so this is no
longer needed. This means that this code will only work with a recent
nightly build, the Arduino 1.5.6 release does not have this fix yet.
matthijskooijman added a commit to Pinoccio/library-pinoccio that referenced this pull request Mar 27, 2014
arduino/Arduino#1798 was merged, so this is no
longer needed. This means that this code will only work with a recent
nightly build, the Arduino 1.5.6 release does not have this fix yet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants