Skip to content
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

dangerous defines #9

Open
proddy opened this issue Feb 19, 2019 · 6 comments
Open

dangerous defines #9

proddy opened this issue Feb 19, 2019 · 6 comments

Comments

@proddy
Copy link

proddy commented Feb 19, 2019

not a bug as such, but be careful with the #DEFINES in EasyBuzzer.h

#ifdef ESP8266
#define min _min
#define max _max
#endif
#ifdef ESP32
#define min _min
#define max _max
#endif

(regardless that they are the same) Any other code that uses the words min or max will be substituted at compile time.

@Mas7ro
Copy link

Mas7ro commented Oct 17, 2019

I've tried the examples and it's run, i included easybuzzer and added some testing line into my code and the CLI don't compile. in my code there are two variables Min and Max. what i can do? thanks.
EDIT: i've changed oders variables names, but same error. I've deleted "IFDEF ESP ecc." lines as above (i use an arduino mega clone) but same error.
here is error log:

Using library EasyBuzzer-master at version 1.0.4 in folder: /Users/Mastro/Documents/Arduino/libraries/EasyBuzzer-master 
exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

@Mas7ro
Copy link

Mas7ro commented Oct 17, 2019

ok, maybe is other kind of error:

Tone.cpp.o (symbol from plugin): In function `timer0_pin_port':
(.text+0x0): multiple definition of `__vector_13'
/var/folders/_6/21prk2wd4dj9btzv4287bzsm0000gn/T/arduino_build_739363/libraries/IRremote/IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here
/Users/Mastro/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino5/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld: Disabling relaxation: it will not work with multiple definitions
collect2: error: ld returned 1 exit status

@Mas7ro
Copy link

Mas7ro commented Oct 17, 2019

It was a conflict with IRremote, this (https://forum.arduino.cc/index.php?topic=120955.0) solved for me.

@dmenne
Copy link

dmenne commented Dec 19, 2019

I agree with @proddy; these redefinitions cause a lot of problems with other code.

@VTeselkin
Copy link

VTeselkin commented Dec 2, 2021

Delete

#ifdef ESP8266
#define min _min
#define max _max
#endif
#ifdef ESP32
#define min _min
#define max _max
#endif

in EasyBuzzer.h
Change to:

/* Beep sequence at a given frequency. /
void EasyBuzzerClass::beep(unsigned int frequency, unsigned int const onDuration, unsigned int const offDuration, byte const beeps, unsigned int const pauseDuration, unsigned int const sequences)
{
mFreq = frequency;
mOnDuration = onDuration ? _max(MINIMUM_INTERVAL, onDuration) : 0;
mOffDuration = offDuration ? _max(MINIMUM_INTERVAL, offDuration) : 0;
mBeeps = beeps;
mPauseDuration = pauseDuration ? _max(MINIMUM_INTERVAL, pauseDuration) : 0;
mSequences = sequences;
mFinishedCallbackFunction = NULL;
mStartTime = _max(millis(), 1);
mLastRunTime = 0;
update();
}
/
Beep sequence at a given frequency, with callback functionality. */
void EasyBuzzerClass::beep(unsigned int frequency, unsigned int const onDuration, unsigned int const offDuration, byte const beeps, unsigned int const pauseDuration, unsigned int const sequences, void (*finishedCallbackFunction)())
{
mFreq = frequency;
mOnDuration = onDuration ? _max(MINIMUM_INTERVAL, onDuration) : 0;
mOffDuration = offDuration ? _max(MINIMUM_INTERVAL, offDuration) : 0;
mBeeps = beeps;
mPauseDuration = pauseDuration ? _max(MINIMUM_INTERVAL, pauseDuration) : 0;
mSequences = sequences;
mFinishedCallbackFunction = finishedCallbackFunction;
mStartTime = _max(millis(), 1);
mLastRunTime = 0;
update();
}

in EasyBuzzer.cpp

@mrNo0b
Copy link

mrNo0b commented Nov 21, 2022

I think there is also conflict with #include <unordered_set>, if I include unordered_set after EasyBuzzer it will not compile with error code 1, I use ESP32 DOIT Devkit V1.
also I had _min error when I used ArduinoSTL IIRC.

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

5 participants