While my first attempt to use AtomThreads with standard Arduino UNO I found that function declarations aren't exported as "C" functions. So, there is simple changes in kernel and avr port to add them.
Sorry, I didn't change other ports just because I don't have other hardware to test it.
Added 'extern C' guards to enable compilation in cross C/C++ environm…
Thanks for the patch Vasily.
So that I can decide on the best place to put the extern C declarations, can you let me know your build environment please? Are you building the Atomthreads C modules as a separate project with a C compiler, and then linking the objects in with your application code built with a C++ compiler?
If the Atomthreads C modules are built separately with a C compiler, can you get the same effect by surrounding the #include's of Atomthreads header files in your application code with extern C declarations?
This is pretty much standard mixed C/C++ project. C code compiled with C compiler, C++ with C++. Linking done with C++ compiler.
Yes, I can surround atomThreas includes with 'extern "C"' declarations but it's really-really bad way. '#ifdef __cplusplus' appoach is commonly used for such projects. For example glibc (or any other linux's libraries includes uses it). Or Parrot VM which is dual-compilable.
Thanks. I'm familiar with the mechanism, although typically I'm working in C and linking with C++ libraries rather than the other way round. Just trying to establish what subset of header files I should roll it out into, including the other architecture ports which are not changed in the pull request.
The main "public" header files are:
The rest of the headers are typically not included by external applications, or are included but only via inclusion from one of the public headers (atom.h etc). I note that your change puts the extern C declarations underneath the inclusion of other headers (e.g. in atom.h it's placed after the other header inclusions). Was there any reason for this or can it be placed above the headers?
My thinking is that I'll place these extern C declarations in the public headers, and the rest of them will work without modification if they are included inside the same declarations. This way we can merge in exact copies of CPU vendor headers unmodified, and don't have to make changes to all of the existing header ports. I'd just like to check with you whether this would work for you. Since you are the best person to test this right now, it would be great if you could try this instead please: just put the extern C declarations in the above 5 files and make sure it surrounds the internal header includes. If that works for you then I'll merge that straight in.
Thanks for your submission & help.
Modifiers now added to the main public header files as described in my last comment. Please let me know if you need find further header files need to be modified. Thanks for your submission.