Hello everyone. I have a watch code working with arduino. However, the code is written in C. When I want to add a code written in C ++, Arduino IDE gives an error. What are your suggestions?
Hello everyone. I have a watch code working with arduino. However, the code is written in C. When I want to add a code written in C ++, Arduino IDE gives an error. What are your suggestions?
A few options come to mind:
- Convert the C++ code that you apparently found to C.
- Convert the C watch code that you wrote to C++ (if you're lucky it might already be valid C++)
- Write a C interface to the C++ code. This could mean using the pimpl/opaque pointer idiom with extern "C" so you can call the C interface from your own code, oblivious to the fact that the actual implementation is in C++.
Generally, it is easier to use a C library from C++ code than vice versa since C is somewhat a subset of C++.
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)
I'm the author of MiniBasic: How to write a script interpreter and Basic Algorithms
Visit my website for lots of associated C programming resources.
https://github.com/MalcolmMcLean