Before logging an issue, please update to the latest release of Visual Micro from the Downloads Page.

When Logging a Support Issue in the Forum, please ensure you have also:-

  • Enabled vMicro > Compiler > Show Build Properties
  • Re-Compile your program with these settings enabled
 
Save the new Output to a Text File and....
  • Click the Reply button and attach as .txt file OR
  • Click here to Email us with the file attached, and a link to your post
Support requests without the output above may be impossible to answer, so please help us to help you
 
Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic #if defined..... Board definitions does not work ? (Read 4331 times)
AggeBitter
Newbies
*
Offline


Posts: 3
Joined: May 11th, 2018
#if defined..... Board definitions does not work ?
May 11th, 2018 at 1:59pm
Print Post  
In my driver header this does not work in vMicro but define correct in Arduino IDE. Any hints ?

// detect Arduino version
#if ARDUINO >= 100
     #include "Arduino.h"
#else
     #include "WProgram.h"
#endif

// determine board type
#if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__)
     String boardName = "Arduino Uno or older";
     
#elif defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega16U4__)
     String boardName = "Arduino Micro or Leonardo";
     
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
     String boardName = "Arduino Mega";
     
#else 
     String boardName = "Unknown board.  Check wikipedia";

#endif
« Last Edit: May 11th, 2018 at 2:00pm by AggeBitter »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: #if defined..... Board definitions does not work ?
Reply #1 - May 11th, 2018 at 3:04pm
Print Post  
Are we talking intellisense or build?

If build please switch on vmicro>compiler>verbose and "show build properties" then post the output after a build or email it to info[at]visualmicro.com along with a link to this thread

Thanks
  
Back to top
IP Logged
 
AggeBitter
Newbies
*
Offline


Posts: 3
Joined: May 11th, 2018
Re: #if defined..... Board definitions does not work ?
Reply #2 - May 11th, 2018 at 8:53pm
Print Post  
Well the compiler take the "board" settings from vMicro. It does not take the arduino board makros that enable if elif else defines in the header files.

this snippet works in a "new" ino file and a new header file but not in my old lib header file. Strange

Code (C++)
Select All
#if defined(TEENSYDUINO)

//  --------------- Teensy -----------------

#if defined(__AVR_ATmega32U4__)
#define BOARD "Teensy 2.0"
#elif defined(__AVR_AT90USB1286__)      
#define BOARD "Teensy++ 2.0"
#elif defined(__MK20DX128__)      
#define BOARD "Teensy 3.0"
#elif defined(__MK20DX256__)      
#define BOARD "Teensy 3.2" // and Teensy 3.1 (obsolete)
#elif defined(__MKL26Z64__)      
#define BOARD "Teensy LC"
#elif defined(__MK64FX512__)
#define BOARD "Teensy 3.5"
#elif defined(__MK66FX1M0__)
#define BOARD "Teensy 3.6"
#else
#error "Unknown board"
#endif

#else // --------------- Arduino ------------------

#if   defined(ARDUINO_AVR_ADK)      
#define BOARD "Mega Adk"
#elif defined(ARDUINO_AVR_BT)    // Bluetooth
#define BOARD "Bt"
#elif defined(ARDUINO_AVR_DUEMILANOVE)      
#define BOARD "Duemilanove"
#elif defined(ARDUINO_AVR_ESPLORA)      
#define BOARD "Esplora"
#elif defined(ARDUINO_AVR_ETHERNET)      
#define BOARD "Ethernet"
#elif defined(ARDUINO_AVR_FIO)      
#define BOARD "Fio"
#elif defined(ARDUINO_AVR_GEMMA)
#define BOARD "Gemma"
#elif defined(ARDUINO_AVR_LEONARDO)      
#define BOARD "Leonardo"
#elif defined(ARDUINO_AVR_LILYPAD)
#define BOARD "Lilypad"
#elif defined(ARDUINO_AVR_LILYPAD_USB)
#define BOARD "Lilypad Usb"
#elif defined(ARDUINO_AVR_MEGA)      
#define BOARD "Mega"
#elif defined(ARDUINO_AVR_MEGA2560)      
#define BOARD "Mega 2560"
#elif defined(ARDUINO_AVR_MICRO)      
#define BOARD "Micro"
#elif defined(ARDUINO_AVR_MINI)      
#define BOARD "Mini"
#elif defined(ARDUINO_AVR_NANO)      
#define BOARD "Nano"
#elif defined(ARDUINO_AVR_NG)      
#define BOARD "NG"
#elif defined(ARDUINO_AVR_PRO)      
#define BOARD "Pro"
#elif defined(ARDUINO_AVR_ROBOT_CONTROL)      
#define BOARD "Robot Ctrl"
#elif defined(ARDUINO_AVR_ROBOT_MOTOR)      
#define BOARD "Robot Motor"
#elif defined(ARDUINO_AVR_UNO)      
#define BOARD "Uno"
#elif defined(ARDUINO_AVR_YUN)      
#define BOARD "Yun"

// These boards must be installed separately:
#elif defined(ARDUINO_SAM_DUE)      
#define BOARD "Due"
#elif defined(ARDUINO_SAMD_ZERO)      
#define BOARD "Zero"
#elif defined(ARDUINO_ARC32_TOOLS)      
#define BOARD "101"
#else
#error "Unknown board"
#endif

#endif 

« Last Edit: May 11th, 2018 at 8:56pm by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: #if defined..... Board definitions does not work ?
Reply #3 - May 11th, 2018 at 8:59pm
Print Post  
Hi,

I am sorry I was not clear in my last post.

The VS C++ intellisense and the compiler are two different software.

I need to see the compiler output. Please click build or try to upload.

When you build the output should say something like "Compiling project foo for board xyz"

Does it build OK? If not then please post the compiler output not the code.

Thanks

  
Back to top
IP Logged
 
AggeBitter
Newbies
*
Offline


Posts: 3
Joined: May 11th, 2018
Re: #if defined..... Board definitions does not work ?
Reply #4 - May 12th, 2018 at 6:54am
Print Post  
After reinstall and upgrade to latest VS and vMicro it gets the right defines so this seems to be solved.


For Arduino Nano:


Board Properties
name=Arduino Nano w/ ATmega328P
upload.tool=avrdude
upload.protocol=arduino
bootloader.tool=avrdude
....
....

Building core ...
l3.5.4-arduino2/bin/avr-gcc" -c -g -x assembler-with-cpp -flto -MMD -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10805 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR res\arduino" riants\eightanaloginputs" s\arduino\wiring_pulse.S" -o iring_pulse.S.o"  



And for ESP32:

Board Properties
name=Heltec_WIFI_LoRa_32
upload.tool=esptool
upload.maximum_size=1044464
upload.maximum_data_size=294912
upload.wait_for_upload_port=true
serial.disableDTR=true
serial.disableRTS=true
build.mcu=esp32
build.core=esp32
build.variant=heltec_wifi_lora_32
build.board=Heltec_WIFI_LoRa_32

....
....

Code
Select All
Building core ...
/bin/xtensa-esp32-elf-gcc" -DESP_PLATFORM -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DHAVE_CONFIG_H nfig" uedroid" p_trace" p_update" otloader_support" " iver" p32" p_adc_cal" hernet" tfs" eertos" ap" mn" g" ns" edtls" edtls_port" wlib" s_flash" enssl" i_flash" mmc" iffs" pip_adapter" p" s" ar_levelling" ensa-debug-module" nsole" c" wlib" ap" a_supplicant" pat" on" http" ip" -std=gnu99 -Os -g3 -fstack-protector -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -nostdlib -Wpointer-arith -w -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wno-unused-parameter -Wno-sign-compare -Wno-old-style-declaration -MMD -c -DF_CPU=240000000L -DARDUINO=10805 -[b]DARDUINO_Heltec_WIFI_LoRa_32[/b] -DARDUINO_ARCH_ESP32 -DARDUINO_BOARD=\"Heltec_WIFI_LoRa_32\" -DESP32 -DCORE_DEBUG_LEVEL=0 -I"C:\Users\Agge\Documents\Arduino\hardware\espressif\esp32\cores\esp32" _lora_32" adc.c" -o \Release\core\esp32-hal-adc.c.o" 




« Last Edit: May 12th, 2018 at 11:20am by Tim@Visual Micro »  
Back to top
 
IP Logged
 
Tim@Visual Micro
Administrator
*****
Offline


Posts: 12191
Location: United Kingdom
Joined: Apr 10th, 2010
Re: #if defined..... Board definitions does not work ?
Reply #5 - May 31st, 2018 at 6:10pm
Print Post  
Off-Topic replies have been moved to this Topic.
  
Back to top
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint