An example of a cpp file that I want to compile differently depending whether it is a program or a library.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
glansberry
Date:
Wed May 06 12:10:43 2015 +0000
Commit message:
initial checkin

Changed in this revision

example.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 e41c1aad3627 example.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/example.cpp	Wed May 06 12:10:43 2015 +0000
@@ -0,0 +1,24 @@
+#include "mbed.h"
+
+class LED_TEST:public DigitalOut{
+   public:
+   LED_TEST(PinName pin):DigitalOut(pin) {};
+
+   void TurnOn() {write(1);}
+   void TurnOff() {write(0);}
+};
+
+#ifdef __IN_A_PROGRAM   //if I'm compiling as a program then I want to create this main for testing.
+                        //if I'm compiling as a library I do not want the main to prevent linker problems
+int main(void)
+{
+LED_TEST lt(LED1);
+    while (1)
+    {
+        lt.TurnOn();
+        wait(1);
+        lt.TurnOff();
+        wait(1);
+    }
+}
+#endif
\ No newline at end of file
diff -r 000000000000 -r e41c1aad3627 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 06 12:10:43 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/8ab26030e058
\ No newline at end of file