arduino-libraries / Ethernet

Ethernet Library for Arduino
http://arduino.cc/
258 stars 263 forks source link

Ethernet library compile warning #122

Closed RichardSelmanXX closed 3 years ago

RichardSelmanXX commented 4 years ago

Moved from https://github.com/arduino/Arduino/issues/9539 by RichardSelmanXX

IDE 1.8.10. Controllino MEGA, simple Ethernet test sketch......

Get this on compile....

In file included from C:\Program Files (x86)\Arduino\libraries\Ethernet\src\Dns.cpp:8:0:

C:\Program Files (x86)\Arduino\libraries\Ethernet\src\Dns.cpp: In member function 'uint16_t DNSClient::BuildRequest(const char*)':

C:\Program Files (x86)\Arduino\libraries\Ethernet\src\utility/w5100.h:457:25: warning: result of '(256 << 8)' requires 18 bits to represent, but 'int' only has 16 bits [-Wshift-overflow=]

 #define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )

                      ~~~^~~

C:\Program Files (x86)\Arduino\libraries\Ethernet\src\Dns.cpp:164:18: note: in expansion of macro 'htons'

  twoByteBuffer = htons(QUERY_FLAG | OPCODE_STANDARD_QUERY | RECURSION_DESIRED_FLAG);

                  ^~~~~
per1234 commented 4 years ago

From the original issue https://github.com/arduino/Arduino/issues/9539: matthijskooijman commented 32 minutes ago

Seems like a warning, which is also harmless (code works as expected AFAICS).

Still would be good to fix, though.

thekunalsaini commented 4 years ago

@RichardSelmanXX Is there any documentation you have follow for this

5kuby commented 4 years ago

is it still unfixed?

ckohrt commented 3 years ago

Any news here?

mgnthe54 commented 3 years ago

Hello, for some time I have also been getting this alert message on one of my PCs .... Anyone have any idea where the warning came from? Thank you

ckohrt commented 3 years ago

Hello, for some time I have also been getting this alert message on one of my PCs .... Anyone have any idea where the warning came from? Thank you

I just ignore it.

mgnthe54 commented 3 years ago

I found this in another post, I did it and I no longer have an error message ... Thanks

https://forum.arduino.cc/t/compiler-message-need-interpretation/620468/7 (post of ToneArt of 04/04/2020)

If you want to avoid the warning, just fix the w5100.h file (in <Arduino install>\libraries\Ethernet\src\Utility):

at the end of the file you have :

#define htons(x) ( (((x)<<8)&0xFF00) | (((x)>>8)&0xFF) )

replace it with this

#define htons(x) ( ((((x)&0xFF)<<8)&0xFF00) | (((x)>>8)&0xFF) )

However, I only had this error message on my desktop computer and not on my other portable computer!

evantill commented 2 years ago

Still present using the latest version of the library (https://github.com/arduino-libraries/Ethernet/releases/tag/2.0.0)

How can we help to have a release including this fix ?

aentinger commented 2 years ago

@evantill here you go: https://github.com/arduino-libraries/Ethernet/releases/tag/2.0.1 .