Skip to content

INADDR_NONE leads to compilation error in Arduino #6610

Closed
@SuGlider

Description

@SuGlider
Collaborator

Board

Any (ESP32, ESP32S2, ESP32S3, ESP32C3)

Device Description

Any - it doesn't matter for the issue

Hardware Configuration

Any - it doesn't matter for the issue

Version

latest master (checkout manually)

IDE Name

Any - it doesn't matter for the issue

Operating System

Any - it doesn't matter for the issue

Flash frequency

80MHz

PSRAM enabled

no

Upload speed

115200

Description

It just need to be compiled and the error will be displayed.
Basically IPAddress INADDR_NONE declared in <IPAddress.h> is replaced by an integer due to any network usage in any Arduino sketch. This issue causes a compilation error.

Sketch

// If it DOESN'T include any Network header file, it works perfectly well! 
// But it makes no sense to do that and use INADDR_NONE...
#include <WiFi.h>
// or just include <ETH.h> 

void setup() {
  Serial.begin(115200);

  // the code line below causes compilation error
  Serial.printf("INADDR_NONE = [%s]", INADDR_NONE.toString());

  // This piece of code compiles, but outputs trash: "IP_NONE addr = [⸮⸮⸮?�]" 
  // it should output [0.0.0.0] instead!
  IPAddress addr = INADDR_NONE; 
  Serial.printf("\n IP_NONE addr = [%s]\n", addr.toString());
}

void loop() {
}

Debug Message

None - just a compilation error message:

Compiling sketch...

C:\Users\espduino\Documents\Arduino\issue_4073_INADDR_UNDEF\issue_4073_INADDR_UNDEF.ino: In function 'void setup()':
issue_4073_INADDR_UNDEF:48:51: error: request for member 'toString' in '4294967295', which is of non-class type 'u32_t' {aka 'unsigned int'}
   Serial.printf("INADDR_NONE = [%s]", INADDR_NONE.toString());
                                                   ^~~~~~~~
Using library WiFi at version 2.0.0 in folder: C:\Users\espduino\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\WiFi 
exit status 1
request for member 'toString' in '4294967295', which is of non-class type 'u32_t' {aka 'unsigned int'}

Other Steps to Reproduce

No response

I have checked existing issues, online documentation and the Troubleshooting Guide

  • I confirm I have checked existing issues, online documentation and Troubleshooting guide.

Activity

added this to the 2.0.3 milestone on Apr 21, 2022
self-assigned this
on Apr 21, 2022
SuGlider

SuGlider commented on Apr 21, 2022

@SuGlider
CollaboratorAuthor

The main issue is that <lwip/inet.h> declares #define INADDR_NONE IPADDR_NONE and it includes <lwip/ip4_addr.h> that declares #define IPADDR_NONE ((u32_t)0xffffffffUL) (IP 255.255.255.255)
When <lwip/inet.h> is included, it makes the Arduino declaration of "IPAddress INADDR_NONE(0,0,0,0)" invalid. This happens in all the Arduino WiFi and ETH libraries.

VojtechBartoska

VojtechBartoska commented on Apr 22, 2022

@VojtechBartoska
Contributor

probably related issue #5220 ?

SuGlider

SuGlider commented on Apr 23, 2022

@SuGlider
CollaboratorAuthor

probably related issue #5220 ?

Yes, it is possible, once IPADDR_NONE will not work at all in Arduino. I'll verify the issue #5220 as well.

update

I checked the issue #5220. WiFiMuilti.ino example seems to be working correctly with 2.0.2 and 2.0.3-RC1.
Thus, it is not related to #6610 issue.

SuGlider

SuGlider commented on Apr 29, 2022

@SuGlider
CollaboratorAuthor

This is another test case used to verify/test this issue and PR Fix:
issue #4732

#include <Arduino.h>
#include <WiFi.h>

void setup() {
  WiFi.begin("Your_SSID", "Your_wifi_password");
  String nodeName = "NODE-" + WiFi.macAddress();
  nodeName.replace(":", "");
  char _nodeName[20]; nodeName.toCharArray(_nodeName, 20);
  WiFi.setHostname(_nodeName);
  WiFi.config(INADDR_NONE, INADDR_NONE, INADDR_NONE);
  WiFi.mode(WIFI_STA);

  log_i("Connected to: ");
  log_i( "%s", WiFi.SSID() );
  log_i( "%s", WiFi.localIP().toString().c_str() );
  log_i( "%s", WiFi.getHostname());
}

void loop() {
}

8 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Relationships

None yet

    Development

    Participants

    @SuGlider@VojtechBartoska

    Issue actions

      INADDR_NONE leads to compilation error in Arduino · Issue #6610 · espressif/arduino-esp32