Cannot find identifiers when compiling android project in visual studio - c++

I successfully generated a visual studio project with Android ndk. Now I am trying to compile such project (by simply opening the solution and the building the BUILD_ALL project). The line I used to compile is the following (I am trying to build Ceres for Android):
cmake -G "Visual Studio 16" -A arm64 -DCMAKE_PREFIX_PATH=D:\DEV\ceres\gflags\build-gflags -DCMAKE_TOOLCHAIN_FILE="C:\Users\l.gagliano\AppData\Local\Android\Sdk\ndk\16.1.4479499\build\cmake\android.toolchain.cmake" -DEigen3_DIR=D:\DEV\ceres\eigen\build -DANDROID_ABI=arm64-v8a -DANDROID_STL=c++_static -DANDROID_NATIVE_API_LEVEL=android-24 -DBUILD_SHARED_LIBS=ON -DMINIGLOG=ON D:\DEV\ceres\ceres-solver-2.1.0
What I get however is a bunch of errors (I only post few of them cause the whole output is too big and moreover they're the same across all the sample projects).
Build started...
1>------ Build started: Project: ceres_internal, Configuration: Debug arm64 ------
1>ANDROID_HOME=C:\\Microsoft\AndroidSDK\25
1>ANT_HOME=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Apps\apache-ant-1.9.3
1>JAVA_HOME=C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot
1>NDK_ROOT=C:\\Microsoft\AndroidNDK64\android-ndk-r16b
1>ANDROID_HOME=C:\\Microsoft\AndroidSDK\25
1>ANT_HOME=C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Apps\apache-ant-1.9.3
1>JAVA_HOME=C:\Program Files\Eclipse Foundation\jdk-8.0.302.8-hotspot
1>NDK_ROOT=C:\\Microsoft\AndroidNDK64\android-ndk-r16b
1>partitioned_matrix_view_2_2_2.cc
1>In file included from <built-in>:370:
1><command line>(3,9): warning : '__ANDROID_API__' macro redefined [-Wmacro-redefined]
1>#define __ANDROID_API__ 24
1> ^
1><command line>(1,9): note: previous definition is here
1>#define __ANDROID_API__ 19
1> ^
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres\generated\partitioned_matrix_view_2_2_2.cc:47:
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres/partitioned_matrix_view_impl.h:31:
1>In file included from C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\algorithm:641:
1>In file included from C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\cstring:61:
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(74,64): error : use of undeclared identifier 'strchr'
1>char* __libcpp_strchr(const char* __s, int __c) {return (char*)strchr(__s, __c);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(81,75): error : use of undeclared identifier 'strpbrk'
1>char* __libcpp_strpbrk(const char* __s1, const char* __s2) {return (char*)strpbrk(__s1, __s2);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(88,65): error : use of undeclared identifier 'strrchr'; did you mean 'strchr'?
1>char* __libcpp_strrchr(const char* __s, int __c) {return (char*)strrchr(__s, __c);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(76,13): note: 'strchr' declared here
1>const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(95,76): error : use of undeclared identifier 'memchr'
1>void* __libcpp_memchr(const void* __s, int __c, size_t __n) {return (void*)memchr(__s, __c, __n);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(102,74): error : use of undeclared identifier 'strstr'; did you mean 'strchr'?
1>char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(78,13): note: 'strchr' declared here
1> char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(102,74): error : no matching function for call to 'strchr'
1>char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(78,13): note: candidate disabled: <no message provided>
1> char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
1> ^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(102,81): error : cannot initialize a parameter of type 'char *' with an lvalue of type 'const char *'
1>char* __libcpp_strstr(const char* __s1, const char* __s2) {return (char*)strstr(__s1, __s2);}
1> ^~~~
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(78,32): note: passing argument to parameter '__s' here
1> char* strchr( char* __s, int __c) {return __libcpp_strchr(__s, __c);}
1> ^
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres\generated\partitioned_matrix_view_2_2_2.cc:47:
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres/partitioned_matrix_view_impl.h:31:
1>In file included from C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\algorithm:641:
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\cstring(70,9): error : no member named 'memcpy' in the global namespace; did you mean 'memchr'?
1>using ::memcpy;
1> ~~^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(97,13): note: 'memchr' declared here
1>const void* memchr(const void* __s, int __c, size_t __n) {return __libcpp_memchr(__s, __c, __n);}
1> ^
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres\generated\partitioned_matrix_view_2_2_2.cc:47:
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres/partitioned_matrix_view_impl.h:31:
1>In file included from C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\algorithm:641:
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\cstring(71,9): error : no member named 'memmove' in the global namespace
1>using ::memmove;
1> ~~^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\cstring(72,9): error : no member named 'strcpy' in the global namespace; did you mean 'strchr'?
1>using ::strcpy;
1> ~~^
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\string.h(76,13): note: 'strchr' declared here
1>const char* strchr(const char* __s, int __c) {return __libcpp_strchr(__s, __c);}
1> ^
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres\generated\partitioned_matrix_view_2_2_2.cc:47:
1>In file included from D:\DEV\ceres\ceres-solver-2.1.0\internal\ceres/partitioned_matrix_view_impl.h:31:
1>In file included from C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\algorithm:641:
1>C:\\Microsoft\AndroidNDK64\android-ndk-r16b\sources\cxx-stl\llvm-libc++\include\cstring(73,9): error : no member named 'strncpy' in the global namespace
1>using ::strncpy;
I am not sure where these error are coming from, my first suspicion is maybe the C++ standard being used but I cannot tell for sure. Can anyone give me an insight of where the problem might be?

The Ceres for Android guide recommends using -DANDROID_STL=c++_shared for building Ceres. You are using -DANDROID_STL=c++_static, so STL is not being detected.
You can find a good explanation here: Confustion about Android NDK libc++ libc++_shared, libstdc++

This worked at the end:
cmake -G "Visual Studio 16" -A arm64 -DCMAKE_PREFIX_PATH=D:\DEV\ceres\gflags\build-gflags -DCMAKE_TOOLCHAIN_FILE="C:\Microsoft\AndroidNDK64\android-ndk-r16b\build\cmake\android.toolchain.cmake" -DEigen3_DIR=D:\DEV\ceres\eigen\build -DANDROID_ABI=arm64-v8a -DANDROID_STL=c++_shared -DANDROID_NATIVE_API_LEVEL=android-24 -DBUILD_SHARED_LIBS=ON -DMINIGLOG=ON -DCMAKE_CXX_STANDARD=14 D:\DEV\ceres\ceres-solver-2.1.0
Namely changing from:
-DCMAKE_TOOLCHAIN_FILE="C:\Users\l.gagliano\AppData\Local\Android\Sdk\ndk\16.1.4479499\build\cmake\android.toolchain.cmake"
To
-DCMAKE_TOOLCHAIN_FILE="C:\Microsoft\AndroidNDK64\android-ndk-r16b\build\cmake\android.toolchain.cmake"
I was generating a visual studio project but with the wrong ndk location (though it was also r16b) but I guess the visual studio one has something special that the other doesn't have.

Related

Qt 'qHash': none of the 23 overloads could convert all the argument types

I am working on plugin development for a tool called Techlog and the tool provides SDK for the development of the plugin.
It uses Qt for the UI.
I am trying to include a header file given by the SDK as shown below.
#include <iostream>
#include <tsdkvariable.h>
using namespace std;
int main(void)
{
cout << "Hello World\n";
}
When I include the file and try to build, I am getting the below error.
Not getting how to proceed further.
error C2665: 'qHash': none of the 23 overloads could convert all the argument types
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(108): note: could be 'uint qHash(std::nullptr_t,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(105): note: or 'uint qHash(QLatin1String,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(104): note: or 'uint qHash(const QBitArray &,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(103): note: or 'uint qHash(QStringView,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(101): note: or 'uint qHash(const QStringRef &,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(100): note: or 'uint qHash(const QString &,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(98): note: or 'uint qHash(const QByteArray &,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(97): note: or 'uint qHash(const QChar,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(95): note: or 'uint qHash(long double,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(93): note: or 'uint qHash(double,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(92): note: or 'uint qHash(float,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(91): note: or 'uint qHash(qint64,uint) noexcept'
3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(87): note: or 'uint qHash(quint64,uint) noexcept'
1>c:\program files\schlumberger\ocean for techlog 2022.1\3rdparty\qt 5.15.2\include\qtcore\qhash.h(291): note: see reference to function template instantiation 'void QHash<T,QHashDummyValue>::detach_helper(void)' being compiled
1> with
1> [
1> T=Slb::Ocean::Techlog::Droid
1> ]
1>c:\program files (x86)\microsoft visual studio\2019\enterprise\vc\tools\msvc\14.16.27023\include\stdexcept(23): note: see reference to class template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>>' being compiled
1>c:\program files\schlumberger\ocean for techlog 2022.1\3rdparty\qt 5.15.2\include\qtcore\qhashfunctions.h(118): error C2056: illegal expression
The qt which comes with SDK doesn't have the qmake...

I am not sure how to use Serial.println [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
I wrote the code below. But Serial.println occurred errors.
I believe in the code is wrong. But I don't know what is wrong.
Could you tell me how to fix the issue?
class Move {
public:
int x;
int y;
void go(int w, int h);
};
void Move::go(int w, int h) {
x += w;
y += h;
}
Move m;
void setup() {
Serial.begin(9600);
m.x = 10;
m.y = 20;
Serial.println("at start: x is %d, y is %d", m.x, m.y);
}
void loop() {
m.go(10, 20);
Serial.println("x is %d, y is %d", m.x, m.y);
}
The error is below:
c:\Users\a\Dropbox\!Arduino\class\classes.ino: In function 'void setup()':
classes:19:58: error: no matching function for call to 'HardwareSerial::println(const char [27], int&, int&)'
Serial.println("at start: x is %d, y is %d", m.x, m.y);
^
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:233,
from sketch\classes.ino.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:77:12: note: candidate: size_t Print::println(const __FlashStringHelper*)
size_t println(const __FlashStringHelper *);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:77:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:78:12: note: candidate: size_t Print::println(const String&)
size_t println(const String &s);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:78:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:79:12: note: candidate: size_t Print::println(const char*)
size_t println(const char[]);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:79:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:80:12: note: candidate: size_t Print::println(char)
size_t println(char);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:80:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:81:12: note: candidate: size_t Print::println(unsigned char, int)
size_t println(unsigned char, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:81:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:82:12: note: candidate: size_t Print::println(int, int)
size_t println(int, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:82:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:83:12: note: candidate: size_t Print::println(unsigned int, int)
size_t println(unsigned int, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:83:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:84:12: note: candidate: size_t Print::println(long int, int)
size_t println(long, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:84:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:85:12: note: candidate: size_t Print::println(long unsigned int, int)
size_t println(unsigned long, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:85:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:86:12: note: candidate: size_t Print::println(double, int)
size_t println(double, int = 2);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:86:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:87:12: note: candidate: size_t Print::println(const Printable&)
size_t println(const Printable&);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:87:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:88:12: note: candidate: size_t Print::println()
size_t println(void);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:88:12: note: candidate expects 0 arguments, 3 provided
c:\Users\a\Dropbox\!Arduino\class\classes.ino: In function 'void loop()':
classes:24:48: error: no matching function for call to 'HardwareSerial::println(const char [17], int&, int&)'
Serial.println("x is %d, y is %d", m.x, m.y);
^
In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Stream.h:26:0,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/HardwareSerial.h:29,
from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Arduino.h:233,
from sketch\classes.ino.cpp:1:
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:77:12: note: candidate: size_t Print::println(const __FlashStringHelper*)
size_t println(const __FlashStringHelper *);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:77:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:78:12: note: candidate: size_t Print::println(const String&)
size_t println(const String &s);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:78:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:79:12: note: candidate: size_t Print::println(const char*)
size_t println(const char[]);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:79:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:80:12: note: candidate: size_t Print::println(char)
size_t println(char);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:80:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:81:12: note: candidate: size_t Print::println(unsigned char, int)
size_t println(unsigned char, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:81:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:82:12: note: candidate: size_t Print::println(int, int)
size_t println(int, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:82:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:83:12: note: candidate: size_t Print::println(unsigned int, int)
size_t println(unsigned int, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:83:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:84:12: note: candidate: size_t Print::println(long int, int)
size_t println(long, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:84:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:85:12: note: candidate: size_t Print::println(long unsigned int, int)
size_t println(unsigned long, int = DEC);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:85:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:86:12: note: candidate: size_t Print::println(double, int)
size_t println(double, int = 2);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:86:12: note: candidate expects 2 arguments, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:87:12: note: candidate: size_t Print::println(const Printable&)
size_t println(const Printable&);
^~~~~~~
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:87:12: note: candidate expects 1 argument, 3 provided
C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:88:12: note: candidate: size_t Print::println()
size_t println(void);
^~~~~~~
Please tell me what is wrong with me.
The problem is that you are using Serial.println() as if it where printf(). Serial.println(), as specified in the documentation, takes only two arguments, the first being the value that you want to print through the serial port, and the second being the format that you want that value to be sent as.
What you need to do to achieve what you originaly wanted is first concatenate the values that you want to send over and then send them with Serial.println().
If you want to print four things, most often the fastest and most efficient way is to simply call print 4 times. Print is pretty lightweight compared to involving format strings. If you're writing for a PC who cares. But if you're writing for a ATTINY or an UNO or something then you can usually use the savings.
Serial.println("at start: x is %d, y is %d", m.x, m.y);
becomes:
Serial.print("at start: x is ");
Serial.print(m.x);
Serial.print(", y is ");
Serial.println(m.y);
Note that I'm using print on all but the last one. Only the last one is println. That way only the last one gives a line break and the receiver doesn't have any way to know if I sent with one statement or three. It all goes in the same buffer and comes out the same way.

Error: 'argument' does not name a type, supposed problems with .cpp and .h files

I read about this issue (seems quite common) for hours without finding any applicable solution to my situation. I understand that there might be a problem related to the included files and libraries, but I'm not actually able to find what's wrong.
It's an Arduino script that uses the MQTT client library. It works beautifully with the old PubSubClient.h lib.
Now I wanted to update the lib with a recent one. The function definitions are changed so I made the changes in the sketch and switched the lib in the Arduino/library directory, then restarted the Arduino IDE. I get lot of "error: 'argument' does not name a type" and I really don't know what to fix.
Here you can find the .h and .cpp files organization to understand what's happening.
//device.ino file
#include "device.h"
//device.h file
#ifndef DEVICE_H
#define DEVICE_H
#include <WiFiClient.h>
#include <WiFiClientSecure.h>
#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <ESP8266HTTPUpdateServer.h>
#include <PubSubClient.h>
#include <ArduinoJson.h>
#include <jsmn.h>
#include <Arduino.h>
#include <pgmspace.h>
#include "mqtt.h"
#endif
mqtt.h file
#ifndef MQTT_H
#define MQTT_H
#include "device.h"
#endif
mqtt.cpp file
#include "mqtt.h"
WiFiClient wifi_client;
PubSubClient mqtt_client(wifi_client);
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
mqtt_client.setCallback(mqtt_callback);
Finally the errors the compiler throws out:
mqtt.cpp:19: error:
'mqtt_client' does not name a type
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
^
mqtt.cpp:20: error: 'mqtt_client' does not name a type
mqtt_client.setCallback(mqtt_callback);
^
sketch\mqtt.cpp: In function 'void mqtt_publish_mex(String, String, bool)':
mqtt.cpp:27: error: no matching function for call to 'PubSubClient::publish(String&, String&, bool&)'
if (mqtt_client.publish(topic, jmex, retained)) {
^
sketch\mqtt.cpp:27:54: note: candidates are:
In file included from sketch\Walvola.h:25:0,
from sketch\mqtt.h:4,
from sketch\mqtt.cpp:1:
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: boolean PubSubClient::publish(const char*, const char*)
boolean publish(const char* topic, const char* payload);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: candidate expects 2 arguments, 3 provided
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: boolean PubSubClient::publish(const char*, const char*, boolean)
boolean publish(const char* topic, const char* payload, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: no known conversion for argument 1 from 'String' to 'const char*'
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: no known conversion for argument 1 from 'String' to 'const char*'
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int, boolean)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: candidate expects 4 arguments, 3 provided
sketch\mqtt.cpp: In function 'void mqtt_log(String)':
mqtt.cpp:347: error: no matching function for call to 'PubSubClient::publish(const String&, String&)'
mqtt_client.publish(mqtt_controllers_topic_debug, json_string);
^
sketch\mqtt.cpp:347:70: note: candidates are:
In file included from sketch\Walvola.h:25:0,
from sketch\mqtt.h:4,
from sketch\mqtt.cpp:1:
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: boolean PubSubClient::publish(const char*, const char*)
boolean publish(const char* topic, const char* payload);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:130:12: note: no known conversion for argument 1 from 'const String' to 'const char*'
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: boolean PubSubClient::publish(const char*, const char*, boolean)
boolean publish(const char* topic, const char* payload, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:131:12: note: candidate expects 3 arguments, 2 provided
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:132:12: note: candidate expects 3 arguments, 2 provided
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: boolean PubSubClient::publish(const char*, const uint8_t*, unsigned int, boolean)
boolean publish(const char* topic, const uint8_t * payload, unsigned int plength, boolean retained);
^
C:\Users\Fabrizio & Dario\Documents\Arduino\libraries\pubsubclient\src/PubSubClient.h:133:12: note: candidate expects 4 arguments, 2 provided
In file included from sketch\mqtt.h:4:0,
from sketch\mqtt.cpp:1:
sketch\mqtt.cpp: In function 'void mqtt_callback(char*, byte*, unsigned int)':
mqtt.cpp:375: error: request for member 'payload_string' in 'payload', which is of non-class type 'byte* {aka unsigned char*}'
log(payload.payload_string());
^
sketch\Walvola.h:89:67: note: in definition of macro 'log'
#define log(mex) if (DEBUG) {Serial.println(walvola_time + "::" + mex);Serial.flush(); if(MQTT_DEBUG) {mqtt_log(walvola_time + "::" + mex);}}
^
mqtt.cpp:375: error: request for member 'payload_string' in 'payload', which is of non-class type 'byte* {aka unsigned char*}'
log(payload.payload_string());
^
sketch\Walvola.h:89:135: note: in definition of macro 'log'
#define log(mex) if (DEBUG) {Serial.println(walvola_time + "::" + mex);Serial.flush(); if(MQTT_DEBUG) {mqtt_log(walvola_time + "::" + mex);}}
^
mqtt.cpp:379: error: request for member 'payload_string' in 'payload', which is of non-class type 'byte* {aka unsigned char*}'
if (mqtt2JSONkvs(payload.payload_string())) {
^
mqtt.cpp:404: error: a function-definition is not allowed here before '{' token
{
^
mqtt.cpp:512: error: expected '}' at end of input
}
^
PiĆ¹ di una libreria trovata per "WiFiClient.h"
Usata: C:\Users\Fabrizio & Dario\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
Non usata: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
'mqtt_client' does not name a type
Thanks for the help!
when writing
WiFiClient wifi_client;
PubSubClient mqtt_client(wifi_client);
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
mqtt_client.setCallback(mqtt_callback);
the first two lines are quite ok => you are declaring global variables named wifi_client and mqtt_client
The problem comes with the calls
mqtt_client.setServer(mqtt_server, MQTT_BROKER_PORT);
mqtt_client.setCallback(mqtt_callback);
You can declare variables at global scope, but you cannot call functions outside a function (unless is for a global variable initialization), this is why you get this error. The example you point is different as the variables are in a function, thus calling methodes on them just after is legal: you are in a function context.
So you need to move your calls in the main() function, for example, so that the code gets valid.
That said, putting global variables in the header could make you more trouble is you include you file from different cpp files, the compiler will complain about multiple definitions, but that is not (yet) the question here.

Using box2d in Codelite IDE

UPDATE: I've gone through and added some apparently missing dependecies of <cwchar> in the files mentioned in the build log. Now I'm down to what appears to be a problem with my cwchar header itself, where it's missing a bunch of declarations. Here's the new build log:
C:\Windows\system32\cmd.exe /C C:/MinGW/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ ncrv3 - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/Michael/Documents/temp/ncrv3'
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/main.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/main.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\string:40,
from C:/Users/Michael/Documents/temp/ncrv3/main.cpp:4:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:177:11: error: '::wcscat' has not been declared
using ::wcscat;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:178:11: error: '::wcscmp' has not been declared
using ::wcscmp;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:179:11: error: '::wcscoll' has not been declared
using ::wcscoll;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:180:11: error: '::wcscpy' has not been declared
using ::wcscpy;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:181:11: error: '::wcscspn' has not been declared
using ::wcscspn;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:183:11: error: '::wcslen' has not been declared
using ::wcslen;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:184:11: error: '::wcsncat' has not been declared
using ::wcsncat;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:185:11: error: '::wcsncmp' has not been declared
using ::wcsncmp;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:186:11: error: '::wcsncpy' has not been declared
using ::wcsncpy;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:188:11: error: '::wcsspn' has not been declared
using ::wcsspn;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:193:11: error: '::wcstok' has not been declared
using ::wcstok;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:196:11: error: '::wcsxfrm' has not been declared
using ::wcsxfrm;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:204:11: error: '::wcschr' has not been declared
using ::wcschr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:205:11: error: '::wcspbrk' has not been declared
using ::wcspbrk;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:206:11: error: '::wcsrchr' has not been declared
using ::wcsrchr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:207:11: error: '::wcsstr' has not been declared
using ::wcsstr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcschr(wchar_t*, wchar_t)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:213:55: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcschr(const_cast<const wchar_t*>(__p), __c); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:212:3: note: initializing argument 1 of 'wchar_t* std::wcschr(wchar_t*, wchar_t)'
wcschr(wchar_t* __p, wchar_t __c)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcspbrk(wchar_t*, const wchar_t*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:217:58: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:216:3: note: initializing argument 1 of 'wchar_t* std::wcspbrk(wchar_t*, const wchar_t*)'
wcspbrk(wchar_t* __s1, const wchar_t* __s2)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcsrchr(wchar_t*, wchar_t)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:221:56: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:220:3: note: initializing argument 1 of 'wchar_t* std::wcsrchr(wchar_t*, wchar_t)'
wcsrchr(wchar_t* __p, wchar_t __c)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcsstr(wchar_t*, const wchar_t*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:225:57: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:224:3: note: initializing argument 1 of 'wchar_t* std::wcsstr(wchar_t*, const wchar_t*)'
wcsstr(wchar_t* __s1, const wchar_t* __s2)
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\string:40:0,
from C:/Users/Michael/Documents/temp/ncrv3/main.cpp:4:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h: In static member function 'static std::size_t std::char_traits<wchar_t>::length(const char_type*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h:358:26: error: 'wcslen' was not declared in this scope
{ return wcslen(__s); }
^
mingw32-make.exe[1]: *** [Debug/main.cpp.o] Error 1
mingw32-make.exe: *** [All] Error 2
ncrv3.mk:105: recipe for target 'Debug/main.cpp.o' failed
mingw32-make.exe[1]: Leaving directory 'C:/Users/Michael/Documents/temp/ncrv3'
Makefile:4: recipe for target 'All' failed
====1 errors, 4 warnings====
OLD:
I want to include the Box2d (2.3.0) library in my command-line project, which I'm working on in CodeLite 9.2.8. There's nothing in Box2d's documentation about codelite support.
Because there's no relevant setup instructions, I tried taking the entire library (Box2D-Master/Box2D/Box2D) and placing it in my project folder, to dynamically link it. Before I even #include "Box2D/Box2D.h", I get 8 warnings leading to one error in the build. What am I doing wrong?
It looks like some declarations are missing, but I have the entire Box2D library here.
There are also some invalid conversions between const wchar* and wchar*.
In my compiler settings, I HAVE enabled c++11 support with -std=c++11. Here is my entire build log.
C:\Windows\system32\cmd.exe /C C:/MinGW/bin/mingw32-make.exe -j4 SHELL=cmd.exe -e -f Makefile
"----------Building project:[ ncrv3 - Debug ]----------"
mingw32-make.exe[1]: Entering directory 'C:/Users/Michael/Documents/temp/ncrv3'
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/Box2D/Dynamics/b2Body.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/Box2D_Dynamics_b2Body.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/Box2D/Dynamics/b2World.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/Box2D_Dynamics_b2World.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/Box2D/Dynamics/b2WorldCallbacks.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/Box2D_Dynamics_b2WorldCallbacks.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/Box2D/Collision/b2BroadPhase.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/Box2D_Collision_b2BroadPhase.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\string:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\random:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stl_algo.h:66,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\algorithm:62,
from ./Box2D/Collision/b2BroadPhase.h:25,
from ./Box2D/Dynamics/b2ContactManager.h:22,
from ./Box2D/Dynamics/b2World.h:25,
from C:/Users/Michael/Documents/temp/ncrv3/Box2D/Dynamics/b2World.cpp:19:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:177:11: error: '::wcscat' has not been declared
using ::wcscat;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:178:11: error: '::wcscmp' has not been declared
using ::wcscmp;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:179:11: error: '::wcscoll' has not been declared
using ::wcscoll;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:180:11: error: '::wcscpy' has not been declared
using ::wcscpy;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:181:11: error: '::wcscspn' has not been declared
using ::wcscspn;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:183:11: error: '::wcslen' has not been declared
using ::wcslen;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:184:11: error: '::wcsncat' has not been declared
using ::wcsncat;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:185:11: error: '::wcsncmp' has not been declared
using ::wcsncmp;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:186:11: error: '::wcsncpy' has not been declared
using ::wcsncpy;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:188:11: error: '::wcsspn' has not been declared
using ::wcsspn;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:193:11: error: '::wcstok' has not been declared
using ::wcstok;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:196:11: error: '::wcsxfrm' has not been declared
using ::wcsxfrm;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:204:11: error: '::wcschr' has not been declared
using ::wcschr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:205:11: error: '::wcspbrk' has not been declared
using ::wcspbrk;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:206:11: error: '::wcsrchr' has not been declared
using ::wcsrchr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:207:11: error: '::wcsstr' has not been declared
using ::wcsstr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcschr(wchar_t*, wchar_t)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:213:55: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcschr(const_cast<const wchar_t*>(__p), __c); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:212:3: note: initializing argument 1 of 'wchar_t* std::wcschr(wchar_t*, wchar_t)'
wcschr(wchar_t* __p, wchar_t __c)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcspbrk(wchar_t*, const wchar_t*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:217:58: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:216:3: note: initializing argument 1 of 'wchar_t* std::wcspbrk(wchar_t*, const wchar_t*)'
wcspbrk(wchar_t* __s1, const wchar_t* __s2)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcsrchr(wchar_t*, wchar_t)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:221:56: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:220:3: note: initializing argument 1 of 'wchar_t* std::wcsrchr(wchar_t*, wchar_t)'
wcsrchr(wchar_t* __p, wchar_t __c)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcsstr(wchar_t*, const wchar_t*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:225:57: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:224:3: note: initializing argument 1 of 'wchar_t* std::wcsstr(wchar_t*, const wchar_t*)'
wcsstr(wchar_t* __s1, const wchar_t* __s2)
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\postypes.h:40:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\string:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\random:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stl_algo.h:66,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\algorithm:62,
from ./Box2D/Collision/b2BroadPhase.h:25,
from C:/Users/Michael/Documents/temp/ncrv3/Box2D/Collision/b2BroadPhase.cpp:19:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:177:11: error: '::wcscat' has not been declared
using ::wcscat;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:178:11: error: '::wcscmp' has not been declared
using ::wcscmp;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:179:11: error: '::wcscoll' has not been declared
using ::wcscoll;
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\string:40:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\random:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stl_algo.h:66,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\algorithm:62,
from ./Box2D/Collision/b2BroadPhase.h:25,
from ./Box2D/Dynamics/b2ContactManager.h:22,
from ./Box2D/Dynamics/b2World.h:25,
from C:/Users/Michael/Documents/temp/ncrv3/Box2D/Dynamics/b2World.cpp:19:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h: In static member function 'static std::size_t std::char_traits<wchar_t>::length(const char_type*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h:358:26: error: 'wcslen' was not declared in this scope
{ return wcslen(__s); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:180:11: error: '::wcscpy' has not been declared
using ::wcscpy;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:181:11: error: '::wcscspn' has not been declared
using ::wcscspn;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:183:11: error: '::wcslen' has not been declared
using ::wcslen;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:184:11: error: '::wcsncat' has not been declared
using ::wcsncat;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:185:11: error: '::wcsncmp' has not been declared
using ::wcsncmp;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:186:11: error: '::wcsncpy' has not been declared
using ::wcsncpy;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:188:11: error: '::wcsspn' has not been declared
using ::wcsspn;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:193:11: error: '::wcstok' has not been declared
using ::wcstok;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:196:11: error: '::wcsxfrm' has not been declared
using ::wcsxfrm;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:204:11: error: '::wcschr' has not been declared
using ::wcschr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:205:11: error: '::wcspbrk' has not been declared
using ::wcspbrk;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:206:11: error: '::wcsrchr' has not been declared
using ::wcsrchr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:207:11: error: '::wcsstr' has not been declared
using ::wcsstr;
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcschr(wchar_t*, wchar_t)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:213:55: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcschr(const_cast<const wchar_t*>(__p), __c); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:212:3: note: initializing argument 1 of 'wchar_t* std::wcschr(wchar_t*, wchar_t)'
wcschr(wchar_t* __p, wchar_t __c)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcspbrk(wchar_t*, const wchar_t*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:217:58: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcspbrk(const_cast<const wchar_t*>(__s1), __s2); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:216:3: note: initializing argument 1 of 'wchar_t* std::wcspbrk(wchar_t*, const wchar_t*)'
wcspbrk(wchar_t* __s1, const wchar_t* __s2)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcsrchr(wchar_t*, wchar_t)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:221:56: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcsrchr(const_cast<const wchar_t*>(__p), __c); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:220:3: note: initializing argument 1 of 'wchar_t* std::wcsrchr(wchar_t*, wchar_t)'
wcsrchr(wchar_t* __p, wchar_t __c)
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar: In function 'wchar_t* std::wcsstr(wchar_t*, const wchar_t*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:225:57: error: invalid conversion from 'const wchar_t*' to 'wchar_t*' [-fpermissive]
{ return wcsstr(const_cast<const wchar_t*>(__s1), __s2); }
^
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\cwchar:224:3: note: initializing argument 1 of 'wchar_t* std::wcsstr(wchar_t*, const wchar_t*)'
wcsstr(wchar_t* __s1, const wchar_t* __s2)
^
In file included from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\string:40:0,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\random:40,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\stl_algo.h:66,
from c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\algorithm:62,
from ./Box2D/Collision/b2BroadPhase.h:25,
from C:/Users/Michael/Documents/temp/ncrv3/Box2D/Collision/b2BroadPhase.cpp:19:
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h: In static member function 'static std::size_t std::char_traits<wchar_t>::length(const char_type*)':
c:\mingw\lib\gcc\mingw32\5.3.0\include\c++\bits\char_traits.h:358:26: error: 'wcslen' was not declared in this scope
{ return wcslen(__s); }
^
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/Box2D/Collision/b2CollideCircle.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/Box2D_Collision_b2CollideCircle.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/Box2D/Collision/b2CollideEdge.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/Box2D_Collision_b2CollideEdge.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
C:/MinGW/bin/g++.exe -c "C:/Users/Michael/Documents/temp/ncrv3/Box2D/Collision/b2CollidePolygon.cpp" -g -O0 -Wall -std=c++11 -DSFML_STATIC -o ./Debug/Box2D_Collision_b2CollidePolygon.cpp.o -I. -IC:\Users\Michael\Documents\SFML\SFML-2.4.1\include
mingw32-make.exe[1]: *** [Debug/Box2D_Collision_b2BroadPhase.cpp.o] Error 1
mingw32-make.exe[1]: *** Waiting for unfinished jobs....
ncrv3.mk:190: recipe for target 'Debug/Box2D_Collision_b2BroadPhase.cpp.o' failed
ncrv3.mk:174: recipe for target 'Debug/Box2D_Dynamics_b2World.cpp.o' failed
mingw32-make.exe[1]: *** [Debug/Box2D_Dynamics_b2World.cpp.o] Error 1
mingw32-make.exe: *** [All] Error 2
mingw32-make.exe[1]: Leaving directory 'C:/Users/Michael/Documents/temp/ncrv3'
Makefile:4: recipe for target 'All' failed
====1 errors, 8 warnings====
I managed to solve my problem, but it's more of a workaround than an actual fix. All functionality is restored by switching from -std=c++11 to -std=gnu++11. So if you have a similar problem, try switching.

ESP8266 error: macro "min" passed 3 arguments, but takes just 2

I'm using PlatformIO to compile my ESP8266 (ESP12e) with Arduino framework. At a certain point, I'm getting errors if I use #include in a certain order.
Below is simplified my code:
platformio.ini
[env:esp12e]
platform = espressif8266
board = esp12e
framework = arduino
upload_speed = 460800
Teste.h
//#include <cstdlib> //<<--this
#include <cstring> //<<-- and/or this causes error!
#include <Arduino.h>
#include <map>
Teste.cpp
#include "Teste.h"
void setup() {}
void loop() {}
Output
$ pio run
Please wait while upgrading PlatformIO ...
Updating atmelavr # 1.3.1: [Up-to-date]
Updating toolchain-atmelavr # 1.40902.0: [Up-to-date]
Updating framework-arduinoavr # 1.10612.1: [Up-to-date]
Updating espressif8266 # 1.3.0: [Up-to-date]
Updating toolchain-xtensa # 1.40802.0: [Up-to-date]
Updating tool-esptool # 1.409.0: [Up-to-date]
Updating tool-mkspiffs # 1.102.0: [Up-to-date]
Updating tool-espotapy # 1.0.0: [Up-to-date]
Updating framework-arduinoespressif8266 # 1.20300.1: [Up-to-date]
Updating sdk-esp8266 # 1.10502.0: [Up-to-date]
PlatformIO has been successfully upgraded to 3.2.1!
[Sun Dec 11 23:02:55 2016] Processing esp12e (platform: espressif8266, lib_deps: PubSubClient, upload_speed: 460800, board: esp12e, framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
Collected 24 compatible libraries
Looking for dependencies...
Library Dependency Graph
|-- <PubSubClient> v2.6
Compiling .pioenvs/esp12e/src/Teste.o
Archiving .pioenvs/esp12e/libFrameworkArduinoVariant.a
Indexing .pioenvs/esp12e/libFrameworkArduinoVariant.a
Compiling .pioenvs/esp12e/FrameworkArduino/Esp.o
In file included from /home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_tree.h:61:0,
from /home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/map:60,
from src/Teste.h:4,
from src/Teste.cpp:1:
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:239:56: error: macro "min" passed 3 arguments, but takes just 2
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:260:56: error: macro "max" passed 3 arguments, but takes just 2
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
Compiling .pioenvs/esp12e/FrameworkArduino/FS.o
Compiling .pioenvs/esp12e/FrameworkArduino/HardwareSerial.o
Compiling .pioenvs/esp12e/FrameworkArduino/IPAddress.o
In file included from src/Teste.h:3:0,
from src/Teste.cpp:1:
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected unqualified-id before 'const'
min(const _Tp& __a, const _Tp& __b)
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected ')' before 'const'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected ')' before 'const'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:193:5: error: expected initializer before 'const'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected unqualified-id before 'const'
max(const _Tp& __a, const _Tp& __b)
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected ')' before 'const'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected ')' before 'const'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:216:5: error: expected initializer before 'const'
In file included from /home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_tree.h:61:0,
from /home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/map:60,
from src/Teste.h:4,
from src/Teste.cpp:1:
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:239:5: error: 'std::min' declared as an 'inline' variable
min(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:239:5: error: template declaration of 'const _Tp& std::min'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:242:7: error: expected primary-expression before 'if'
if (__comp(__b, __a))
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:242:7: error: expected '}' before 'if'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:244:7: error: expected unqualified-id before 'return'
return __a;
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:260:5: error: 'max' declared as an 'inline' variable
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:260:5: error: template declaration of 'const _Tp& max'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:263:7: error: expected primary-expression before 'if'
if (__comp(__a, __b))
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:263:7: error: expected '}' before 'if'
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:265:7: error: expected unqualified-id before 'return'
return __a;
^
/home/erico/.platformio/packages/toolchain-xtensa/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:266:5: error: expected declaration before '}' token
}
^
Compiling .pioenvs/esp12e/FrameworkArduino/MD5Builder.o
Compiling .pioenvs/esp12e/FrameworkArduino/Print.o
*** [.pioenvs/esp12e/src/Teste.o] Error 1
============================================================================================ [ERROR] Took 0.47 seconds ============================================================================================
Did I miss something? Maybe a bug in Arduino Framework or Espressif SDK?
The <Arduino.h> header defines max and min macros. It really shouldn't do that. To get around the problem, add
#undef max
#undef min
right after your #include <Arduino.h> line.