Platformio-core: Compiling difference between Arduino IDE and Platformio

Created on 10 Feb 2016  路  17Comments  路  Source: platformio/platformio-core

Moved from https://github.com/platformio/platformio-atom-ide/issues/38

First, let me say thank you for this incredible Atom plugin!!! It majorly improves my dev time compared with the Arduino IDE!
I successfully compiled and uploaded a few programs for Arduino Due, but I ran into one bug.
The following program compiles, uploads and works with the Arduino IDE:

char myBuffer[5] = {' ', ' ', ' ', ' ', ' '};
void setup() {}

void loop() {
  SerialUSB.println(fillMyBuffer());
  delay(1000);
}

char* fillMyBuffer() {
  for (int i = 0; i < 5; i++) {
    myBuffer[i] = 'A';
  }
  return myBuffer;
}

Using Atom + Platformio, I get the following build error:
error: 'fillMyBuffer' was not declared in this scope

Here's what's on the build panel:

Executing: platformio run 
[02/10/16 12:25:42] Processing dueUSB (platform: atmelsam, board: dueUSB, framework: arduino)

[02/10/16 12:25:42] Processing dueUSB (platform: atmelsam, board: dueUSB, framework: arduino)

arm-none-eabi-g++ -o .pioenvs\dueUSB\src\tmp_ino_to.o -c -fno-rtti -fno-exceptions -g -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -nostdlib -DF_CPU=84000000L -DUSBCON -DUSB_MANUFACTURER="PlatformIO" -Dprintf=iprintf -D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -DUSB_VID=0x2341 -DUSB_PID=0x003e "-DUSB_PRODUCT=\"Arduino Due\"" -DARDUINO=10606 -DPLATFORMIO=020804 -I.pioenvs\dueUSB\FrameworkArduino -I.pioenvs\dueUSB\FrameworkCMSISInc -I.pioenvs\dueUSB\FrameworkLibSam -I.pioenvs\dueUSB\FrameworkLibSam\include -I.pioenvs\dueUSB\FrameworkDeviceInc -I.pioenvs\dueUSB\FrameworkDeviceInc\3x8e\include -I.pioenvs\dueUSB\FrameworkArduinoVariant src\tmp_ino_to.cpp
arm-none-eabi-g++ -o .pioenvs\dueUSB\src\tmp_ino_to.o -c -fno-rtti -fno-exceptions -g -Os -ffunction-sections -fdata-sections -Wall -mthumb -mcpu=cortex-m3 -nostdlib -DF_CPU=84000000L -DUSBCON -DUSB_MANUFACTURER="PlatformIO" -Dprintf=iprintf -D__SAM3X8E__ -DARDUINO_SAM_DUE -DARDUINO_ARCH_SAM -DUSB_VID=0x2341 -DUSB_PID=0x003e "-DUSB_PRODUCT=\"Arduino Due\"" -DARDUINO=10606 -DPLATFORMIO=020804 -I.pioenvs\dueUSB\FrameworkArduino -I.pioenvs\dueUSB\FrameworkCMSISInc -I.pioenvs\dueUSB\FrameworkLibSam -I.pioenvs\dueUSB\FrameworkLibSam\include -I.pioenvs\dueUSB\FrameworkDeviceInc -I.pioenvs\dueUSB\FrameworkDeviceInc\3x8e\include -I.pioenvs\dueUSB\FrameworkArduinoVariant src\tmp_ino_to.cpp
AtomTest.ino: In function 'void loop()':
AtomTest.ino:7:32: error: 'fillMyBuffer' was not declared in this scope
AtomTest.ino: In function 'void loop()':
AtomTest.ino:7:32: error: 'fillMyBuffer' was not declared in this scope
scons: *** [.pioenvs\dueUSB\src\tmp_ino_to.o] Error 1
 [ ERROR ] Took 2.92 seconds 
scons: *** [.pioenvs\dueUSB\src\tmp_ino_to.o] Error 1
 [ ERROR ] Took 2.88 seconds 

Thanks again!

bug

Most helpful comment

Done! Cheers :-)

All 17 comments

Hello, I seem to have the same problem on Windows 10 64-bit, just installed platformio IDE 1.2.1 core 3.2.1 with clang & python 2.7, all is updated.

What can I provide / how to troubleshoot? Compilation works perfectly fine on Arduino IDE.

Error: C:/Users/Massi/Dropbox/Arduino, RPi, Adafruit/test/m0_mudra_bleuart_v1.1/m0_mudra_bleuart_v1.1/m0_mudra_bleuart_v1.1.ino:168:51: error: 'isUSBOn' was not declared in this scope

Many thanks

Moving methods loop() and setup() at the very end of the .ino file, after all accessory methods, seems to have resolved the issue. Still, a discrepancy between Arduino IDE and Platformio. I suspect it's some build flag re. forward reference but cannot find where to look for it ...

@mbariola Could you provide INO file to reproduce this issue? It looks that INO to CPP converter doesn't work correctly in your case. Thanks.

@ivankravets sure, is there a way to send it privately to you? it is a project I want to develop commercially and so I'd like to not attach it publicly here

Of course, please send to [email protected]. I'll not share it.

Thanks @ivankravets , just sent.

@mbariola Thanks a lot for provided demo project. Our INO to CPP is VERY STRICT. See

Please remove spaces/tabs before bool isUSBOn().

@mbariola Please note that I deleted your email and all tracks related to your project.

@ivankravets so it was a spurious space character? wow, I'd have never guessed (nor found) that. I removed it and all compiles. Thanks for your troubleshooting, confidentiality and quick answer. Now I know what to look for if it ever pops up again. cheers!

@mbariola yes, we don't catch spaces before types of prototypes. It will break general regular expression.

A few recommendations to your project:

  1. Please remove lib_dir from [platformio] section in platformio.ini
  2. Use PlatformIO's Library Manager and lib_deps option
  3. http://docs.platformio.org/en/latest/librarymanager/index.html

ok, I can't say I comprehend the why of what you suggest me to do as I picked platformio just 3 days ago and had used arduino.cc's manager to not change too much in one go, but I'll clone the project to be sure and follow your instructions. it'll help me in familiarizing with the platform. thanks!

OK, done, took just a few minutes and properly separating general libs such as the adafruit bluetooth one from the project specific ones such as BluefruitConfig.h. Thanks!

Happy coding with PlatformIO! 馃槉

@mbariola would be thankful for a star 馃専

gladly, how would I do it? star your profile .. this issue .. the project ...?

star ... the project

Yes, please use "馃専 Star" button above.

Done! Cheers :-)

Was this page helpful?
0 / 5 - 0 ratings