SimpleIDE programming question
NWCCTV
Posts: 3,629
This may seem a bit out there but I have a question about the SimpleIDE Library and header files. Is it possible to use a completed C project and save the C file as a Header? In other words, kind of like how SPIN handles Objects. So, could I, as an example, save the libCompass3d project as a .h Header file to be used in another project?
Comments
C++ makes it easier because the scope of symbols can be limited to classes to avoid a "global catastrophe" of functions and variables, etc....
For every C program, there is a function called "main(...)" that serves as the start point of the program. If you create .h "header libraries", the function "main(...)" must not be included in the header.
There are many other considerations. An experienced C programmer could deal with them, but it can still be frustrating.
Let's say you have two such programs and you want to combine them into a single application.
That won't fly as the C compiler want's to have only one "main" as that is where everything is started from and you can't have two starting points.
What to do?
Change the names of those "main" functions to something else reflecting whatever those program do.
Create a new file with a "main" that now starts those two new functions. Perhaps one is a started in a new COG and the other is called directly to run in the current cog.
How you get those two programs now running together concurrently to communicate with each other is another matter.