I'm a novice with STM32 and Keil. I'd like to use a BMP280 C library and a RFM69 C++ library. I wasn't able to understand how to use both in the same project. Can someone share some advice/guidance? The C++ library uses .hpp files and they were not recognized. I was probably making a mistake. Thank you in advance for any help.
Frank
here is how i do it and it works
stmmxcube-> generate code for keil
compile code in keil
in keil-> right click main.c->options for file main.c->file type->c++ source file
now you can add c++ header files and it will work
when you regenerate code form stm cubemx repeat steps
i generally add c++ files from arduino and make them compatable
it works always
some functions are still not supported
currently c++17 is supported
The techniques for mixing 'C' and C++ are standard - not specific to Keil - so should be covered in standard references.
one key factor is the use of
extern "C"
I'm a novice with STM32 and Keil
Are you familiar with using STM32 in any other IDE(s) ?
Are you familiar with using any other microcontroller(s) ?
Are you familiar with 'C' and/or C++ programming in general ?
For learning, start here:
http://www2.keil.com/mdk5/learn
See also: https://www.keil.com/books/
Thank you very much. I will try that.
Thank you. I will take a look at those resources. No I've not used STM32 in other IDE's. I've used other microcontrollers, but at a higher level of abstraction. I am familiar with C and a have less experience with C++ .
Btw - see: "How do I call C++ code from C?"
www.keil.com/.../4245.htm
manually writing the prototype multiple times with different formats in different files is a maintenance nightmare!
That example misses the usual practice of using a #ifdef __cplusplus so that the same header can be used by both .c and .cpp files:
#ifdef __cplusplus extern "C" { #endif void myFunc(int); #ifdef __cplusplus } #endif
Thanks again for your reply. I still receive this error:
Error: C4065E: type of input file \RFM69-STM32-master\rfm69.hpp' unknown
Do you have any suggestions to resolve it?
Please dis-regard my last error post, I didn't catch that it added the hpp as a source file instead of a text file. Your solution worked. Thanks again.