I am using the current standard Ethernet lib, and get the following preprocessor/compiler messages, and have no idea how to interpret them or whether or not they require a change to the code. Help in understanding what they are saying would be much appreciated -- can't seem to find pretinent info on the web... I only know that the first line indicates that in line 8, column 0 (?) of Dns.cpp there is some kind of issue -- can't find the DNSClient code -- don't know what "::" means....etc.
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=]
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);
^~~~~
The first part of Dns.cpp is below... line 8 is '#include "utility/w5100.h"'
```
// Arduino DNS client for WizNet5100-based Ethernet shield
// (c) Copyright 2009-2010 MCQN Ltd.
// Released under Apache License, version 2.0
#include <Arduino.h>
#include "Ethernet.h"
#include "Dns.h"
#include "utility/w5100.h"
#define SOCKET_NONE 255
// Various flags and header field values for a DNS message
#define UDP_HEADER_SIZE 8
#define DNS_HEADER_SIZE 12
```
Did your error messages really have smiley faces in them? That's very friendly!!! Post your errors using code tags just like you did with your sketch and they'll appear properly.
Sorry -- code for Dns.cpp is attached..and compiler messages are below
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);
^~~~~
Sketch uses 26488 bytes (86%) of program storage space. Maximum is 30720 bytes.
Global variables use 1296 bytes (63%) of dynamic memory, leaving 752 bytes for local variables. Maximum is 2048 bytes.
The compiler is actually correct. The hex value is 0x0100 and it is complaining because the 1 bit is being shifted out, however this is OK for this purpose. The warning does not prevent the software from building.
The first portion of the macro isolates the LSB to the MSB and the second portion isolates the MSB to the LSB and then ORs them together to create a network-ordered (big endian) 16-bit value.