with gcc-arm-none-eabi-7-2017-q4-major the default typedef of time_t is "long long int". older releases typedef time_t as "long int". mbed lib cannot handle this correctly This applies to exported projects as "GCC (ARM-Embedded)"

Dependencies:   mbed

Fork of USBSerial_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
bomilkar
Date:
Wed Feb 07 10:30:36 2018 +0000
Parent:
9:d88699a0905a
Commit message:
This testcase demonstrates the incompatibility of time_t when using gcc-arm-none-eabi-7-2017-q4-major.; The symptom is apparent with "sizeof(time_t)"; The 2017-q4 release shows 8 "long long int"; Older releases show 4 "long int"

Changed in this revision

USBDevice.lib Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r d88699a0905a -r ee0528f8d38e USBDevice.lib
--- a/USBDevice.lib	Fri Mar 01 13:33:02 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/USBDevice/#335f2506f422
diff -r d88699a0905a -r ee0528f8d38e main.cpp
--- a/main.cpp	Fri Mar 01 13:33:02 2013 +0000
+++ b/main.cpp	Wed Feb 07 10:30:36 2018 +0000
@@ -1,14 +1,43 @@
 #include "mbed.h"
-#include "USBSerial.h"
- 
-//Virtual serial port over USB
-USBSerial serial;
- 
-int main(void) {
- 
-    while(1)
-    {
-        serial.printf("I am a virtual serial port\r\n");
+
+#define SERIAL_TX PA_9
+#define SERIAL_RX PA_10
+Serial pc(SERIAL_TX, SERIAL_RX, 115200);
+
+int main(void)
+{
+    time_t t;
+    struct tm *tx;
+
+    pc.printf("++++++++++++++++++++++\nsizeof(time_t) = %d\n++++++++++++++++++++++\n",sizeof(time_t));
+
+    time(&t);
+    pc.printf("read RTC: %u\n",(int)t);
+    tx = localtime(&t);
+    pc.printf("ctime: %s", ctime(&t));
+    pc.printf("T: %d:%d:%d D: %d.%d.%d X: %d\n",
+              tx->tm_hour,tx->tm_min,tx->tm_sec,
+              tx->tm_mday,tx->tm_mon+1,tx->tm_year+1900,
+              tx->tm_isdst);
+
+    pc.printf("t = 0\n");
+    t = 0;
+    tx = localtime(&t);
+    pc.printf("ctime: %s", ctime(&t));
+    pc.printf("T: %d:%d:%d D: %d.%d.%d X: %d\n",
+              tx->tm_hour,tx->tm_min,tx->tm_sec,
+              tx->tm_mday,tx->tm_mon+1,tx->tm_year+1900,
+              tx->tm_isdst);
+
+    pc.printf("loop start\n");
+    while (1) {
+        tx = localtime(&t);
+        pc.printf("ctime: %s", ctime(&t));
+        pc.printf("T: %d:%d:%d D: %d.%d.%d X: %d\n",
+                  tx->tm_hour,tx->tm_min,tx->tm_sec,
+                  tx->tm_mday,tx->tm_mon+1,tx->tm_year+1900,
+                  tx->tm_isdst);
         wait(1);
+        t += 1;
     }
-}
\ No newline at end of file
+}
diff -r d88699a0905a -r ee0528f8d38e mbed.bld
--- a/mbed.bld	Fri Mar 01 13:33:02 2013 +0000
+++ b/mbed.bld	Wed Feb 07 10:30:36 2018 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/3d0ef94e36ec
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/7130f322cb7e
\ No newline at end of file