Skip to content

'min' was not declared in this scope #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
blurfl opened this issue May 18, 2015 · 9 comments
Closed

'min' was not declared in this scope #263

blurfl opened this issue May 18, 2015 · 9 comments

Comments

@blurfl
Copy link

blurfl commented May 18, 2015

A trivial sketch raises a compile error "'min' was not declared in this scope".
I don't know enough to dig further, but one clue might be that commenting out the line:

include "FileSystem.h"

in Arduino.h allows the trivial sketch to compile.


Arduino: 1.6.5 (Mac OS X), Board: "Generic ESP8266 Module, 80 MHz, 115200, 512K (64K SPIFFS)"

junk.ino: In function 'void setup()':
junk:3: error: 'min' was not declared in this scope
junk.ino:3:16: note: suggested alternative:
In file included from /Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/memory:62:0,
from /Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/FileSystem.h:24,
from /Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/Arduino.h:214,
from junk.ino:1:
/Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:239:5: note: 'std::min'
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
junk:4: error: 'max' was not declared in this scope
junk.ino:4:16: note: suggested alternative:
In file included from /Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/memory:62:0,
from /Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/FileSystem.h:24,
from /Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/Arduino.h:214,
from junk.ino:1:
/Users/username/Desktop/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:260:5: note: 'std::max'
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
'min' was not declared in this scope


[code]
// junk.ino
void setup() {
int x = min(3,4);
int y = max(3,4);
}
void loop() {
}
[/code]

@blurfl
Copy link
Author

blurfl commented May 18, 2015

The most recent commit, 'fix tools path', seems to have fixed this, so closing....

@blurfl blurfl closed this as completed May 18, 2015
@blurfl
Copy link
Author

blurfl commented May 18, 2015

It appears I didn't test enough; the issue still occurs :(

@blurfl blurfl reopened this May 18, 2015
@igrr igrr closed this as completed in 07ecca1 May 18, 2015
@redflag2k
Copy link

I just download 1.6.5 via http://arduino.esp8266.com/staging/package_esp8266com_index.json .

I have same issue and same error message with blurfl.

This error is not occurred when I use 1.64 version.

How can I fix it?

Thanks in advance.

@ghost
Copy link

ghost commented Sep 4, 2015

Id fixed this while adding

#define min(a,b) ((a)<(b)?(a):(b))

to my sketch.

igrr added a commit that referenced this issue Oct 29, 2015
@NickWaterton
Copy link

Min/max seems broken again in latest git version as of today.

@Links2004
Copy link
Collaborator

min and max are not working in all cases since the define can brake normal c++ features like std::vector they are disabled in some cases.
you can try _min and _max they are allways defined and not brake c++

https://github.com/esp8266/Arduino/blob/master/cores/esp8266/Arduino.h#L251-L258

@peteroid
Copy link

peteroid commented May 3, 2016

Same issue of "'min' was not found in this scope". Just install the ver 2.2.0

@janfiess
Copy link

Same here with 1.6.9.
However only if the sketch contains other libraries for the ESP8266 (ESP8266WiFi.h, WiFiUdp.h, OSCMessage.h).
Is there a solution?

@colonialT
Copy link

Had the same issue, min() worked before adding the following libraries:

#include <ESP8266WiFi.h> #include <WiFiUdp.h> #include <OSCMessage.h> #include <OSCData.h>

I replaced min() with _min() which compiled and worked with a simple print sketch I used to test it.

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

No branches or pull requests

7 participants