Error 'max' was not declared in this scope

Background: My goal with this code is to display a four digit number to a 4 x seven segment LED using the SevenSeg library. In the future, I plan on it displaying the temperature from a thermometer probe using the OneWire library and the Dallas Temperature library. For the time being, those libraries are not being used.

When I verify/upload this code using the Arduino online editor to a Raspberry Pi (cloud) I get the following error.

I am very new to Arduino and I honestly have no idea what this means, or how to fix it. Any suggestions or links to other documentation is helpful. Thanks!

Sketch…

// Test sketch to see if manual code of 7-Segment LEDs work with SevenSeg Library
// SevenSeg - Version: Latest 
#include <SevenSeg.h>

// DallasTemperature - Version: Latest 
#include <DallasTemperature.h>

// OneWire - Version: Latest 
#include <OneWire.h>

SevenSeg disp (36, 38, 40, 7, 11, 13, 15);
const int numOfDigits=4;
int digitPins[numOfDigits]={12, 16, 18, 32};
int DPPin=29;


void setup() {
    disp.setDigitPins(numOfDigits,digitPins);
    disp.setCommonCathode();
    disp.setDPPin(DPPin);
}

void loop() {
    disp.write(2300,2);
  }

Bottom half of the status…

...
Compiling library "dallastemperature_3_8_0"

"/home/ubuntu/opt/tools/arm-linux-gcc/4.9.3/bin/arm-linux-gnueabihf-g++" -c -I. -w -g -O3 -nostdlib -DMRAA_BACKEND -DN_I2C=3 -DN_SPI=3 -MMD -std=gnu++11 -mtune=cortex-a9 -DARDUINO=10611 -DARDUINO_ARM_V7 -DARDUINO_ARCH_MRAA -DARDUINO_LINUX "-I/home/ubuntu/opt/cores/arduino/mraa/cores/linux" "-I/home/ubuntu/opt/cores/arduino/mraa/variants/linux-armv7" "-I/home/ubuntu/opt/libraries/latest/sevenseg_1_2_1" "-I/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0" "-I/tmp/321647877/custom/OneWire" "/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp" -o "/tmp/321647877/build/libraries/dallastemperature_3_8_0/DallasTemperature.cpp.o"

Multiple libraries were found for "DallasTemperature.h"

Used: /home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0

Not used: /home/ubuntu/opt/libraries/latest/max31850_dallastemp_1_0_0

Multiple libraries were found for "OneWire.h"

Used: /tmp/321647877/custom/OneWire

Not used: /home/ubuntu/opt/libraries/latest/onewire_2_3_4

Not used: /home/ubuntu/opt/libraries/latest/max31850_onewire_1_0_1

Using library sevenseg_1_2_1 at version 1.2.1 in folder: /home/ubuntu/opt/libraries/latest/sevenseg_1_2_1

Using library dallastemperature_3_8_0 at version 3.8.0 in folder: /home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0

Using library OneWire at version 2.3.2 in folder: /tmp/321647877/custom/OneWire

/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp: In member function 'void DallasTemperature::begin()':

/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp:99:67: error: 'max' was not declared in this scope

bitResolution = max(bitResolution, getResolution(deviceAddress));

^

/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp:99:67: note: suggested alternative:

In file included from /home/ubuntu/opt/tools/arm-linux-gcc/4.9.3/arm-linux-gnueabihf/include/c++/4.9.3/bits/char_traits.h:39:0,

from /home/ubuntu/opt/tools/arm-linux-gcc/4.9.3/arm-linux-gnueabihf/include/c++/4.9.3/string:40,

from /home/ubuntu/opt/cores/arduino/mraa/cores/linux/mraa/common.hpp:29,

from /home/ubuntu/opt/cores/arduino/mraa/cores/linux/mraa.hpp:27,

from /home/ubuntu/opt/cores/arduino/mraa/variants/linux-armv7/variant.h:11,

from /home/ubuntu/opt/cores/arduino/mraa/variants/linux-armv7/pins_arduino.h:20,

from /home/ubuntu/opt/cores/arduino/mraa/cores/linux/Arduino.h:4,

from /tmp/321647877/custom/OneWire/OneWire.h:7,

from /home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.h:22,

from /home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp:6:

/home/ubuntu/opt/tools/arm-linux-gcc/4.9.3/arm-linux-gnueabihf/include/c++/4.9.3/bits/stl_algobase.h:261:5: note: 'std::max'

max(const _Tp& __a, const _Tp& __b, _Compare __comp)

^

/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp: In member function 'bool DallasTemperature::setResolution(const uint8_t*, uint8_t, bool)':

/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp:278:52: error: 'max' was not declared in this scope

bitResolution = max(bitResolution, newResolution);

^

/home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp:278:52: note: suggested alternative:

In file included from /home/ubuntu/opt/tools/arm-linux-gcc/4.9.3/arm-linux-gnueabihf/include/c++/4.9.3/bits/char_traits.h:39:0,

from /home/ubuntu/opt/tools/arm-linux-gcc/4.9.3/arm-linux-gnueabihf/include/c++/4.9.3/string:40,

from /home/ubuntu/opt/cores/arduino/mraa/cores/linux/mraa/common.hpp:29,

from /home/ubuntu/opt/cores/arduino/mraa/cores/linux/mraa.hpp:27,

from /home/ubuntu/opt/cores/arduino/mraa/variants/linux-armv7/variant.h:11,

from /home/ubuntu/opt/cores/arduino/mraa/variants/linux-armv7/pins_arduino.h:20,

from /home/ubuntu/opt/cores/arduino/mraa/cores/linux/Arduino.h:4,

from /tmp/321647877/custom/OneWire/OneWire.h:7,

from /home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.h:22,

from /home/ubuntu/opt/libraries/latest/dallastemperature_3_8_0/DallasTemperature.cpp:6:

/home/ubuntu/opt/tools/arm-linux-gcc/4.9.3/arm-linux-gnueabihf/include/c++/4.9.3/bits/stl_algobase.h:261:5: note: 'std::max'

max(const _Tp& __a, const _Tp& __b, _Compare __comp)

^

exit status 1

Moderator edit: code and error inline

error.doc (34.5 KB)

test.ino (552 Bytes)

So you are new to arduino and want to upload code to a Raspberry Pi (cloud)?? Did I miss something here?

(I’m on a mobile so can’t and won’t read your attachments, why don’t you just post the content here using the right tags)

The Arduino libraries were not written for the Raspberry Pi platform so you are going to encounter a lot of problems like this where code that would run fine on a standard Arduino board won’t work. I believe in this case you would need to edit the DallasTemperature library to make it work for Raspberry Pi. It looks like you can resolve the issue by changing max() to std::max(). Some Arduino sketches/libraries will work fine. This is also a very new part of the Arduino project so you are likely to run into more bugs (though I wouldn’t necessarily say this is one).

I don’t think programming the Raspberry Pi via the Arduino Web Editor is the best choice for a beginner. You will have an easier time if you buy a standard Arduino board like Uno, Nano, Leonardo, Pro Micro, or Mega. If you’re set on this path and have enough perseverance then I think you will eventually be successful.