diff --git a/miosix/_doc/textdoc/Changelog.txt b/miosix/_doc/textdoc/Changelog.txt index d8f06f5d6da772f70f4d114fbcda28a43f36f85e..2b71e3f9ed2888077652d3c4557df840c1e4a2b9 100644 --- a/miosix/_doc/textdoc/Changelog.txt +++ b/miosix/_doc/textdoc/Changelog.txt @@ -1,5 +1,8 @@ Changelog for Miosix np embedded OS + +v2.01 +- Added preliminary C++11 support v2.0 - Added support for new board, oledboard2 - Added support for new board, tempsensor diff --git a/miosix/config/Makefile.inc b/miosix/config/Makefile.inc index dfc9f8153a1974f28537661a72a928eb5bc1dd69..06c4a8ad7bad3066ed59b081c1913fa3e4e63568 100644 --- a/miosix/config/Makefile.inc +++ b/miosix/config/Makefile.inc @@ -365,7 +365,7 @@ endif ## CFLAGS_BASE := -D_MIOSIX_BOARDNAME=\"$(OPT_BOARD)\" \ -Wno-unused-but-set-variable -CXXFLAGS_BASE := -D_MIOSIX_BOARDNAME=\"$(OPT_BOARD)\" \ +CXXFLAGS_BASE := -std=gnu++11 -D_MIOSIX_BOARDNAME=\"$(OPT_BOARD)\" \ -Wno-unused-but-set-variable ## diff --git a/miosix/e20/e20.cpp b/miosix/e20/e20.cpp index 973a34e398c087b92ff1868230666e5e6cb63796..558054cf00416b3f77417ae13d11ef0e79737768 100644 --- a/miosix/e20/e20.cpp +++ b/miosix/e20/e20.cpp @@ -28,7 +28,9 @@ #include "e20.h" using namespace std; +#if __cplusplus <= 199711L using namespace std::tr1; +#endif //!c++11 namespace miosix { diff --git a/miosix/e20/e20.h b/miosix/e20/e20.h index 7012b30622588403fd55b402db71940169a92954..4f53a4164d1effb8b9cb46a9c6ce4cf80ddd03c0 100644 --- a/miosix/e20/e20.h +++ b/miosix/e20/e20.h @@ -31,7 +31,14 @@ #define E20_H #include <list> +#if __cplusplus > 199711L +#include <functional> +//TODO: remove this once we make the full transition to C++11 +#define FUN_NAMESPACE std +#else //c++11 #include <tr1/functional> +#define FUN_NAMESPACE std::tr1 +#endif //c++11 #include <miosix.h> #include "callback.h" @@ -64,7 +71,7 @@ public: * run() or runOne(). Bind can be used to bind parameters to the function. * \throws std::bad_alloc if there is not enough heap memory */ - void post(std::tr1::function<void ()> event); + void post(FUN_NAMESPACE::function<void ()> event); /** * This function blocks waiting for events being posted, and when available @@ -104,7 +111,7 @@ private: EventQueue(const EventQueue&); EventQueue& operator= (const EventQueue&); - std::list<std::tr1::function<void ()> > events; ///< Event queue + std::list<FUN_NAMESPACE::function<void ()> > events; ///< Event queue mutable FastMutex m; ///< Mutex for synchronisation ConditionVariable cv; ///< Condition variable for synchronisation }; diff --git a/miosix/util/unicode.h b/miosix/util/unicode.h index 00f97bfbc3df598aa610a1481e97db829bc46107..da9a81b0bf757c503557e2e2ca03821bcbf8b9bb 100644 --- a/miosix/util/unicode.h +++ b/miosix/util/unicode.h @@ -31,9 +31,11 @@ #ifndef UNICODE_H #define UNICODE_H -//TODO: these should be provided by the compiler, byt they're not +#if __cplusplus <= 199711L +//These are builtin types in C++11, add them if compiling in C++03 mode typedef uint16_t char16_t; typedef uint32_t char32_t; +#endif // !c++11 namespace miosix { diff --git a/miosix/util/version.cpp b/miosix/util/version.cpp index e6155bdca97f06d0d65be3692430e9069574f785..8257135702c4651dbb9dc55f3c3bf56668e2ac43 100644 --- a/miosix/util/version.cpp +++ b/miosix/util/version.cpp @@ -28,6 +28,9 @@ #include "config/miosix_settings.h" #include "board_settings.h" +// These two #if are here because version checking for config files in +// out-of-git-tree projects has to be done somewhere. + #if MIOSIX_SETTINGS_VERSION != 100 #error You need to update miosix_settings.h to match the version in the kernel. #endif @@ -38,17 +41,25 @@ namespace miosix { -#ifdef __GNUC__ #define tts(x) #x #define ts(x) tts(x) -#define CV ", gcc "ts(__GNUC__)"."ts(__GNUC_MINOR__)"."ts(__GNUC_PATCHLEVEL__) + +#ifdef __clang__ //clang also defines GNUC, so it has to go first +#define CV ", clang " \ + ts(__clang_major__) "." ts(__clang_minor__) "." ts(__clang_patchlevel__) \ + "-mp" ts(_MIOSIX_CLANG_PATCH_VERSION) +#define AU __attribute__((used)) +#elif defined(__GNUC__) +#define CV ", gcc " \ + ts(__GNUC__) "." ts(__GNUC_MINOR__) "." ts(__GNUC_PATCHLEVEL__) \ + "-mp" ts(_MIOSIX_GCC_PATCH_VERSION) #define AU __attribute__((used)) #else #define CV #define AU #endif -const char AU ver[]="Miosix v2.0 (" _MIOSIX_BOARDNAME ", " __DATE__ " " __TIME__ CV ")"; +const char AU ver[]="Miosix v2.01 (" _MIOSIX_BOARDNAME ", " __DATE__ " " __TIME__ CV ")"; const char *getMiosixVersion() {