ERROR asm invalid output constraint with clang

I’m using clang for syntax checking and it shows the error:

.platformio/packages/toolchain-atmelavr/avr/include/util/delay_basic.h:108:5: error: invalid output constraint '=w' in asm
                : "=w" (__count)

I followed the set up instructions for Emacs from the website and from GitHub - ZachMassia/PlatformIO-Mode: PlatformIO Integration for Emacs

I can use the platformio CLI to build and load the code, but in Emacs clang shows the error. Do you use some options in particular so it works fine?

There were similar issues with Atom, see PlatformIO IDE for Atom: Go To Declaration - #14 by DerTomm

Any suggestions?


Morning All,

I’m seeing exactly this problem on a PlatformIO project created with pio init --board uno --ide qtcreator and containing a very basic “blink” sketch. As I’m using QTCreator as my IDE, and definitely not using Emacs (It’s usually vi for me! :wink:), I don’t think that the problem is related to Emacs.

I build a small blink project as follows:

mkdir testQT
cd testQT
pio init --board uno --ide qtcreator

cd ..
mkdir testCB
cd testCB
pio init --board uno --ide codeblocks

In either test directory, pio run -e uno works fine, no problems at all.

In the CodeBlocks test, both the Debug and Release targets build fine too. Looking at the build options, the compiler is my 64bit g++, but when compiling, it actually calls out to pio run so builds fine. This is interesting as there is a compiler listed - the AVR version of g++ so it could be used.

In the QTCreator IDE, there is no AVR specific version of g++ found in the compilers listed under Options, and compiling is carried out using the default g++ compiler - for 64bit x86 style environments. QTCreator projects don’t appear to call out to pio run.

So, I suspect your Emacs setup is calling the wrong compiler?

FYI, my platformio.ini file is this:

platform = atmelavr
board = uno
;framework = arduino

I commented out the framework line.

And the test source, main.cpp is this:

#include <avr/io.h>
#include <util/delay.h>

int main ()
    // setup
    DDRB |= (1 << DDB5);

    // loop
    while (1) {
        PINB |= (1 << PINB5);
    return 0;