Skip to content

_BV was not declared in this scope while trying to compile Marlin #147

@dc740

Description

@dc740

The error log is extensive, but it simply complains about _BV being out of scope. This can be reproduced by compiling Marling on branch bugfix-2.0.x (I haven't tried the 1.1 branch)

#######
Workaround:
Locate the packages directory (linux: inside ~/.arduino15) and find the Arduino.h file inside MCUdude_corefiles directory.

~/.arduino15/packages/MightyCore/hardware/avr/2.0.4/cores/MCUdude_corefiles/Arduino.h
(update the version as needed)

Add this:

#ifndef _BV
#define _BV(bit) (1 << (bit))
#endif

#######

Error log when not using the workaround:

Arduino: 1.8.9 (Linux), Board: "ATmega1284, Yes (UART0), Standard pinout, 1284P, BOD 2.7V, LTO disabled, External 16 MHz"

In file included from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:19:0,
                 from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/Arduino.h:290,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/../shared/Marduino.h:33,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/HAL.h:27,
                 from sketch/src/lcd/dogm/../../inc/MarlinConfig.h:30,
                 from sketch/src/lcd/dogm/HAL_LCD_class_defines.h:24,
                 from sketch/src/lcd/dogm/ultralcd_DOGM.h:31,
                 from sketch/src/lcd/dogm/lcdprint_u8g.cpp:14:
/home/dc740/arduino-1.8.9/hardware/tools/avr/avr/include/avr/power.h: In function 'void clock_prescale_set(clock_div_t)':
/home/dc740/arduino-1.8.9/hardware/tools/avr/avr/include/avr/power.h:1511:31: error: '_BV' was not declared in this scope
     uint8_t __tmp = _BV(CLKPCE);
                               ^
In file included from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:14:0,
                 from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/Arduino.h:290,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/../shared/Marduino.h:33,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/HAL.h:27,
                 from sketch/src/lcd/dogm/../../inc/MarlinConfig.h:30,
                 from sketch/src/lcd/dogm/HAL_LCD_class_defines.h:24,
                 from sketch/src/lcd/dogm/ultralcd_DOGM.h:31,
                 from sketch/src/lcd/dogm/lcdprint_u8g.cpp:14:
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void enableSleep()':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:81:5: error: '_BV' was not declared in this scope
     sleep_enable();
     ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void disableSleep()':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:90:5: error: '_BV' was not declared in this scope
     sleep_disable();
     ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void sleepMode(uint8_t)':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:102:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_IDLE);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:107:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_ADC);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:112:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_PWR_DOWN);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:117:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_PWR_SAVE);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:122:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_STANDBY);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:127:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_EXT_STANDBY);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void sleep()':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:148:5: error: '_BV' was not declared in this scope
     sleep_mode();
     ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:148:5: error: '_BV' was not declared in this scope
     sleep_mode();
     ^
In file included from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:19:0,
                 from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/Arduino.h:290,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/../shared/Marduino.h:33,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/HAL.h:27,
                 from sketch/src/lcd/dogm/../../inc/MarlinConfig.h:30,
                 from sketch/src/lcd/dogm/HAL_LCD_class_defines.h:24,
                 from sketch/src/lcd/dogm/ultralcd_DOGM.h:31,
                 from sketch/src/lcd/dogm/ultralcd_DOGM.cpp:42:
/home/dc740/arduino-1.8.9/hardware/tools/avr/avr/include/avr/power.h: In function 'void clock_prescale_set(clock_div_t)':
/home/dc740/arduino-1.8.9/hardware/tools/avr/avr/include/avr/power.h:1511:31: error: '_BV' was not declared in this scope
     uint8_t __tmp = _BV(CLKPCE);
                               ^
In file included from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:14:0,
                 from /home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/Arduino.h:290,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/../shared/Marduino.h:33,
                 from sketch/src/lcd/dogm/../../inc/../HAL/HAL_AVR/HAL.h:27,
                 from sketch/src/lcd/dogm/../../inc/MarlinConfig.h:30,
                 from sketch/src/lcd/dogm/HAL_LCD_class_defines.h:24,
                 from sketch/src/lcd/dogm/ultralcd_DOGM.h:31,
                 from sketch/src/lcd/dogm/ultralcd_DOGM.cpp:42:
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void enableSleep()':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:81:5: error: '_BV' was not declared in this scope
     sleep_enable();
     ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void disableSleep()':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:90:5: error: '_BV' was not declared in this scope
     sleep_disable();
     ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void sleepMode(uint8_t)':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:102:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_IDLE);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:107:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_ADC);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:112:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_PWR_DOWN);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:117:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_PWR_SAVE);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:122:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_STANDBY);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:127:9: error: '_BV' was not declared in this scope
         set_sleep_mode(SLEEP_MODE_EXT_STANDBY);
         ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h: In function 'void sleep()':
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:148:5: error: '_BV' was not declared in this scope
     sleep_mode();
     ^
/home/dc740/.arduino15/packages/MightyCore/hardware/avr/2.0.2/cores/MCUdude_corefiles/wiring_extras.h:148:5: error: '_BV' was not declared in this scope
     sleep_mode();
     ^
exit status 1
Error compiling for board ATmega1284.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions