Demo for GetTypeName library, using all defined types.

Dependencies:   GetTypeName mbed

Files at this revision

API Documentation at this revision

Comitter:
frankvnk
Date:
Sun Feb 15 21:18:58 2015 +0000
Commit message:
initial release

Changed in this revision

GetTypeName.lib Show annotated file 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 000000000000 -r 51ba9e864352 GetTypeName.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/GetTypeName.lib	Sun Feb 15 21:18:58 2015 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/frankvnk/code/GetTypeName/#9723189e1955
diff -r 000000000000 -r 51ba9e864352 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Feb 15 21:18:58 2015 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+#include "GetTypeName.h"
+
+int main()
+{
+    char a = 65;
+    uint8_t b = 20;
+    signed char c = -30;
+    int8_t d = -40;
+    unsigned short e = 50;
+    uint16_t f = 60;
+    short g = -70;
+    int16_t h = -80;
+    unsigned int i = 90;
+    uint32_t j = 100;
+    int k = -110;
+    int32_t l = -120;
+    unsigned long long m = 130;
+    uint64_t n = 140;
+    long long o = -150;
+    int64_t p = -160;
+    float q = 1.7;
+    double r = 1.8;
+    bool s = 1;
+
+    printf("Type name for <char> '%c' is %s\r\n", a, GetTypeName(a));
+    printf("Type name for <uint8_t> %d is %s\r\n", b, GetTypeName(b));
+    printf("Type name for <signed char> %d is %s\r\n", c, GetTypeName(c));
+    printf("Type name for <int8_t> %d is %s\r\n", d, GetTypeName(d));
+    printf("Type name for <unsigned short> %d is %s\r\n", e, GetTypeName(e));
+    printf("Type name for <uint16_t> %d is %s\r\n", f, GetTypeName(f));
+    printf("Type name for <short> %d is %s\r\n", g, GetTypeName(g));
+    printf("Type name for <int16_t> %d is %s\r\n", h, GetTypeName(h));
+    printf("Type name for <unsigned int> %d is %s\r\n", i, GetTypeName(i));
+    printf("Type name for <uint32_t> %d is %s\r\n", j, GetTypeName(j));
+    printf("Type name for <int> %d is %s\r\n", k, GetTypeName(k));
+    printf("Type name for <int32_t> %d is %s\r\n", l, GetTypeName(l));
+    printf("Type name for <unsigned long long> %lld is %s\r\n", m, GetTypeName(m));
+    printf("Type name for <uint64_t> %lld is %s\r\n", n, GetTypeName(n));
+    printf("Type name for <long long> %lld is %s\r\n", o, GetTypeName(o));
+    printf("Type name for <int64_t> %lld is %s\r\n", p, GetTypeName(p));
+    printf("Type name for <float> %f is %s\r\n", q, GetTypeName(q));
+    printf("Type name for <double> %f is %s\r\n", r, GetTypeName(r));
+    printf("Type name for <bool> %d is %s\r\n", s, GetTypeName(s));
+    
+    // Store GetTypeName in a variable
+    const char *VarType;
+    VarType = GetTypeName(a);
+    printf("'%c' is of '%s' type\r\n", a, VarType);
+    
+    // Check whether GetTypeName is of 'char' type.
+    // Note that strcmp returns 0 when both strings are equal.
+    if(!strcmp(GetTypeName(a),"char")) printf("'%c' is of 'char' type\r\n", a);
+}
diff -r 000000000000 -r 51ba9e864352 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Feb 15 21:18:58 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/e188a91d3eaa
\ No newline at end of file