Skip to content

INADDR_NONE leads to compilation error in Arduino #6610

Closed
@SuGlider

Description

@SuGlider

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.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions