Skip to content

Commit 2ef7a61

Browse files
committed
Enable automatic declaration of cout/cerr. Application must still define them. This allows other libraries to link against this, because other libraries assume cout/cerr.
1 parent 7197d27 commit 2ef7a61

File tree

8 files changed

+18
-13
lines changed

8 files changed

+18
-13
lines changed

StandardCplusplus.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#undef abs

examples/serstream/Jamfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# (1) Project Information
22

3-
PROJECT_LIBS = uclibcpp ;
3+
PROJECT_LIBS = StandardCplusplus ;
44

55
# (2) Board Information
66

examples/serstream/serstream.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44

55
using namespace std;
66

7-
ohserialstream cout(Serial);
7+
// <iostream> declares cout/cerr, but the application must define them
8+
// because it's up to you what to do with them.
9+
namespace std
10+
{
11+
ohserialstream cout(Serial);
12+
}
813

914
void setup(void)
1015
{

examples/string_vector/Jamfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# (1) Project Information
22

3-
PROJECT_LIBS = uclibcpp ;
3+
PROJECT_LIBS = StandardCplusplus ;
44

55
# (2) Board Information
66

examples/string_vector/string_vector.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66

77
using namespace std;
88

9-
ohserialstream cout(Serial);
9+
// <iostream> declares cout/cerr, but the application must define them
10+
// because it's up to you what to do with them.
11+
namespace std
12+
{
13+
ohserialstream cout(Serial);
14+
}
1015

1116
vector<string> strings;
1217

ios.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
namespace std{
3434

3535
#ifdef __UCLIBCXX_SUPPORT_CDIR__
36-
#ifndef ARDUINO
3736
_UCXXLOCAL int ios_base::Init::init_cnt = 0; //Needed to ensure the static value is created
3837

3938
//Create buffers first
@@ -90,9 +89,6 @@ namespace std{
9089
_UCXXEXPORT wostream wclog(&_wclog_filebuf);
9190
#endif
9291

93-
#endif // not ARDUINO
94-
95-
#ifdef ARDUINO
9692

9793
#ifdef __UCLIBCXX_SUPPORT_COUT__
9894
_UCXXEXPORT ohserialstream cout(Serial);
@@ -107,9 +103,6 @@ namespace std{
107103
_UCXXEXPORT ohserialstream clog(Serial);
108104
#endif
109105

110-
#endif // ARDUINO
111-
112-
113106
_UCXXEXPORT ios_base::Init::Init(){
114107
if(init_cnt == 0){ //Need to construct cout et al
115108

@@ -201,7 +194,6 @@ namespace std{
201194
mprecision = prec;
202195
return temp;
203196
}
204-
205197
_UCXXEXPORT streamsize ios_base::width(streamsize wide){
206198
streamsize temp = mwidth;
207199
mwidth = wide;

iostream

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <istream>
2828
#include <ostream>
2929
#ifdef ARDUINO
30+
#include <serstream>
3031
#else
3132
#include <fstream>
3233
#endif

system_configuration.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
#define __UCLIBCXX_IOSTREAM_BUFSIZE__ 32
2525
#undef __UCLIBCXX_HAS_LFS__
2626
#undef __UCLIBCXX_SUPPORT_CDIR__
27-
27+
#define __UCLIBCXX_SUPPORT_COUT__
28+
#define __UCLIBCXX_SUPPORT_CERR__
2829
/*
2930
* STL and Code Expansion
3031
*/

0 commit comments

Comments
 (0)