mborgerson
Well-known member
I have 4 different models of Teensy (3.2, 3.5, 3.6, 4.0) and they have all provided many hours of educational and interesting hardware and programming projects. There are lots of excellent libraries for the Teensy boards and I have learned a lot from examining their source code. However, when I read through the source I often get lost in the sea of #ifdef statements that allow the same source file to work with the various Teensy boards. It is troubling to be working on at T3.6 project and reading through a library source code file only to find an "#endif" statement at the bottom of the screen. I start to wonder if I have been reading through the source for at T3.2 or T4.0 and have to scroll back up to find the matching #if defined(Teensy_3_6).
This leads me to the following questions:
1. Is there a text processing tool that will allow me to sort through the #define statements in a source code file and eliminate all the source for processors other than the one I select?
2. What are the pros and cons of writing library code with one large source file using #ifdef to handle multiple processors or boards versus writing separate source code files for each processor (which will need far fewer #ifdef statements, but have more files to maintain)?
I guess I was spoiled by spending a few decades where I designed systems from the bottom up. I got to pick the processor, design the circuit, lay out the PCB, and write the firmware. About the only #ifdef statements in my code were "#ifdef DEBUGPRINT". As a result the customer got firmware source for the board in hand and didn't have to cope with lines of code designed for someone else's board.
What is the current preference of the computer science academic community on this topic? I've only had a few lower-division programming courses (back in the late 1960's) so I'm a bit out of touch with academic opinion. Being self taught can go a long ways if you pick a narrow enough field of endeavor, but it can lead to a bit of tunnel vision.
This leads me to the following questions:
1. Is there a text processing tool that will allow me to sort through the #define statements in a source code file and eliminate all the source for processors other than the one I select?
2. What are the pros and cons of writing library code with one large source file using #ifdef to handle multiple processors or boards versus writing separate source code files for each processor (which will need far fewer #ifdef statements, but have more files to maintain)?
I guess I was spoiled by spending a few decades where I designed systems from the bottom up. I got to pick the processor, design the circuit, lay out the PCB, and write the firmware. About the only #ifdef statements in my code were "#ifdef DEBUGPRINT". As a result the customer got firmware source for the board in hand and didn't have to cope with lines of code designed for someone else's board.
What is the current preference of the computer science academic community on this topic? I've only had a few lower-division programming courses (back in the late 1960's) so I'm a bit out of touch with academic opinion. Being self taught can go a long ways if you pick a narrow enough field of endeavor, but it can lead to a bit of tunnel vision.