Hello,
I was working on a project on Visual Studio Code -platform IO and it was building normally. Then, I had to install the C++ compiler on VS code for another thing that I was working on (following the instructions on https://www.msys2.org) where I had to download some toolchains but when I went back to my original project on PIO, it stopped building showing the below errors:
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:442:5: error: expected ‘}’ before ‘typedef’
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:442:5: error: ‘_Dom’ was not declared in this scope
_DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
^
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:442:5: note: suggested alternative: ‘_Pow’
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:442:5: error: template argument 3 is invalid
_DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
^
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:442:5: error: expected unqualified-id before ‘return’
_DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
^
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:442:5: error: ‘_Expr’ does not name a type; did you mean ‘_Exit’?
_DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
^
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:443:5: error: ‘_Expr’ does not name a type; did you mean ‘_Exit’?
_DEFINE_EXPR_UNARY_FUNCTION(cos, _Cos)
^
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:443:5: error: ‘_Expr’ does not name a type; did you mean ‘_Exit’?
_DEFINE_EXPR_UNARY_FUNCTION(cos, _Cos)
^
c:\users\rayan.platformio\packages\toolchain-gccarmnoneeabi\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:444:5: error: ‘_Expr’ does not name a type; did you mean ‘_Exit’?
_DEFINE_EXPR_UNARY_FUNCTION(acos, _Acos)
Any idea how to solve this please
seems like the issue is from the bits/stdc++.h library, when I commented this line
#include<bits/stdc++.h> I was able to build normally. It was working before normally, any suggestions how to fix this please
Remove
c:\users\rayan\.platformio\packages\toolchain-gccarmnoneeabi
c:\users\rayan\.platformio\.cache
and rebuild the project as a first cleaning countermeasure. If it still doesn’t work, post your full platformio.ini
and reference code.
Hello, I tried deleting these folders but the same error persisted.
Please find attached the configuration file and below is a part of my code

#include <dl_datatype.h>
#include<bits/stdc++.h> //comment this line to build successfully
using namespace std;
class Queue
{
// Initialize front and rear
int rear, front;
// Circular Queue
int size;
//RAY
uint_32 *arr;
public:
Queue(int s);
//RAY
void enQueue(uint32_t value);
int deQueue();
void displayQueue();
uint_32 ui32GetSum();
};
I’m not sure whether it’s a good idea to include the entirety of all C++ headers like this.
Headers like Arduino.h
usually #undef
parts of the include, like abs()
, max()
, min()
etc to substitute their own. Doing a #include<bits/stdc++.h>
breaks that again, and it shows in the error messages.
Compiling .pio\build\adafruit_feather_nrf52840_sense\src\main.cpp.o
In file included from c:\users\max\.platformio\packages\toolchain-gccarmnoneeabi@1.70201.0\arm-none-eabi\include\c++\7.2.1\valarray:592:0,
from c:\users\max\.platformio\packages\toolchain-gccarmnoneeabi@1.70201.0\arm-none-eabi\include\c++\7.2.1\arm-none-eabi\thumb\v7e-m\fpv4-sp\hard\bits\stdc++.h:95,
from src\main.cpp:4:
c:\users\max\.platformio\packages\toolchain-gccarmnoneeabi@1.70201.0\arm-none-eabi\include\c++\7.2.1\bits\valarray_after.h:442:42: error: macro "abs" passed 2 arguments, but takes just 1
_DEFINE_EXPR_UNARY_FUNCTION(abs, _Abs)
^
In file included from src\main.cpp:1:0:
c:\users\max\.platformio\packages\toolchain-gccarmnoneeabi@1.70201.0\arm-none-eabi\include\c++\7.2.1\complex:69:30: error: expected unqualified-id before 'const'
template<typename _Tp> _Tp abs(const complex<_Tp>&);
So, looks like bad code to me. You possibly triggered it by #include <Arduino.h>
in the dl_datatype.h
file?
I’d suggest to only #include <stdint.h>
and use uint32_t
consistently. You mix uint_32
and uint32_t
in your code.
Okay this makes sense, will fix and clean my code and header files.
Thank you !