Dear Matej, I want to thank you for creating these wonderful videos, it's truly helpful and rare. I hope you will continue your passion, thank you very much.
Hi, could you continue with the series? I need these c++ embedded tutorial very bad.
2 роки тому
I'm compiling (heh) a list of points for a video. Mostly things c++ is better out of the box, features, encapsulation, modern compile time features and so on. I'll try squeezing one out in a week.
I have heard of rust beeing used for embedded, but I don't intend to pick it up any time soon. C++ is, in my opinion, easier step from C, as it more or less adds to the language, rather than beeing a different one. I just happen to use more and more c++ in my career so I'm focusing on that.
Sorry, but how to use c++ for vs code? I can't do it 2 week, because not search information for settings. I have Linux Ubuntu, gcc-arm-none-eabi, cortex debag extension, for c this setup work is good, but c++, a big problem for me . Compiler mark the c++ code red lines 😢 .
Рік тому
Which part does not work correctly? Compiling or just IDE syntax highlighting?
Hi, Matej! Nice video. I try to implement your code in my project with STM32F446ZE and I did corresponding changes but I have some questions. I have a message that says “not found stddef.h” but my code compile and I can blink to Led, I don't know if I can fix it. My main question is how can I implement class with c++ I want to create a class to manage many sensors and this recourse is necessary for this. I tried to implement it with .cpp file but I had an error saying “class symbol not accepted”. If you can help me I will be very grateful!! Thanks
2 роки тому
I would advise a coulple of things: - the thing with "not found stddef.h": Please confirm that you have completely installed toolchain. Some linux distributions might carry some parts in other packages. If you use windows and you installed the package as in video 48, then you're fine. I would check if your path is active. Just test if compiler is found in cmd or powershell: arm-none-eabi-gcc --version. - the one with "class symbol not accepted" might come from using a .c or .h file, that is included in a .c file. You cannot define a class or any c++ only feature in a header file, that is also included in a .c source. Make sure to separate it with some pure functions. Also, if you're using CubeIDE, check if you have converted the project to a C++ project. In project includes make sure that you have a path to your C++ headers and source files so that the ide will find them. If you follow my cmake example, where I defined a struct with a few methods, you should be good to go.
@ Hi Matej, thank you for your advice. I tell you what I did. First began to write only C code where your videos guided me. I could compile and debug with JLink by VSCode whitout problems. I have I2C accelerometer sensor and I send messages by UART without problems. But my code is large enough and I wanted to create a class to manage the sensor. Then I was guided by your 47 video to implement this. Here is where I have many problems. Is it possible to create a class and call it by main.c ? Before I use Mbed OS and CLI 2 to program my STM32 where the main file is .cpp and I could call the class but I found your way by Make is more easy and simple. On another side, I run arm-none-eabi-gcc --version and I got this "arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)" it seems to be well installed I don't know why I got the error with the "stddef.h" library, in my others projects this works well. I'm using fedora. I hope you can help me, you have been my guide in my development in STM and I am very grateful.
2 роки тому
Great. Now as I said in my first reply, you cannot use c++ constructs and features in C. They are compatible, but not fully. That's why I created my "second main" file where you can use C++. You can also rename main.c to main.cpp but the next time you run cubemx it will add main.c back as it sees it missing (could be solved in future update). Then you will have two main functions and the compiler will shout at you. Also I think its much neater to store all mcu peripheral initializations in main.c and use your own vode in "projectMain.cpp". So, if you want to use a class, define it in a header, maybe implenentation in a .cpp file and use it in projectMain.cpp.. Follow the example repositort on github "stm32-cmake" and "stm32". All C->C++ "communication" has to be done via C style pure functions. Afain thats why I use prokectMain.cpp.
@ Hi Matej! Thank you once again for your help. Finally, I'm using "projectMain.cpp" file and create my classes in separate files and I can tell them without any problems. My code compiles and debugs without problems but I have problems with the next warning: cannot open source file "stddef.h" . This message red underline #include "main.h" and #include "stdio.h" statements. Do you know how can I fix it?
Dear Matej,
I want to thank you for creating these wonderful videos, it's truly helpful and rare.
I hope you will continue your passion, thank you very much.
Thank you for a very useful video.
Thanks!! Good video!
Hi, could you continue with the series? I need these c++ embedded tutorial very bad.
I'm compiling (heh) a list of points for a video. Mostly things c++ is better out of the box, features, encapsulation, modern compile time features and so on. I'll try squeezing one out in a week.
Hi. Very good channel for embedded world programmers. Will you add any updates to channel content?
Soon, when I find more time and energy :)
I USE C ON STM32
Have u ever tried Rust Lang with embedded, i think u might be interested
Great video btw
I have heard of rust beeing used for embedded, but I don't intend to pick it up any time soon. C++ is, in my opinion, easier step from C, as it more or less adds to the language, rather than beeing a different one. I just happen to use more and more c++ in my career so I'm focusing on that.
Sorry, but how to use c++ for vs code? I can't do it 2 week, because not search information for settings. I have Linux Ubuntu, gcc-arm-none-eabi, cortex debag extension, for c this setup work is good, but c++, a big problem for me . Compiler mark the c++ code red lines 😢 .
Which part does not work correctly? Compiling or just IDE syntax highlighting?
@ if compiling from console, is ok. But in vs code, i can't to setting cmake, and syntax highlights.
if you could do an overview on setting up vs code for c++ it would be very great for many embedders
Hi, Matej! Nice video. I try to implement your code in my project with STM32F446ZE and I did corresponding changes but I have some questions. I have a message that says “not found stddef.h” but my code compile and I can blink to Led, I don't know if I can fix it. My main question is how can I implement class with c++ I want to create a class to manage many sensors and this recourse is necessary for this. I tried to implement it with .cpp file but I had an error saying “class symbol not accepted”.
If you can help me I will be very grateful!!
Thanks
I would advise a coulple of things:
- the thing with "not found stddef.h": Please confirm that you have completely installed toolchain. Some linux distributions might carry some parts in other packages. If you use windows and you installed the package as in video 48, then you're fine. I would check if your path is active. Just test if compiler is found in cmd or powershell: arm-none-eabi-gcc --version.
- the one with "class symbol not accepted" might come from using a .c or .h file, that is included in a .c file. You cannot define a class or any c++ only feature in a header file, that is also included in a .c source. Make sure to separate it with some pure functions.
Also, if you're using CubeIDE, check if you have converted the project to a C++ project. In project includes make sure that you have a path to your C++ headers and source files so that the ide will find them.
If you follow my cmake example, where I defined a struct with a few methods, you should be good to go.
@ Hi Matej, thank you for your advice.
I tell you what I did. First began to write only C code where your videos guided me. I could compile and debug with JLink by VSCode whitout problems. I have I2C accelerometer sensor and I send messages by UART without problems. But my code is large enough and I wanted to create a class to manage the sensor. Then I was guided by your 47 video to implement this. Here is where I have many problems. Is it possible to create a class and call it by main.c ?
Before I use Mbed OS and CLI 2 to program my STM32 where the main file is .cpp and I could call the class but I found your way by Make is more easy and simple.
On another side, I run arm-none-eabi-gcc --version and I got this "arm-none-eabi-gcc (GNU Arm Embedded Toolchain 10.3-2021.10) 10.3.1 20210824 (release)" it seems to be well installed I don't know why I got the error with the "stddef.h" library, in my others projects this works well. I'm using fedora.
I hope you can help me, you have been my guide in my development in STM and I am very grateful.
Great.
Now as I said in my first reply, you cannot use c++ constructs and features in C. They are compatible, but not fully. That's why I created my "second main" file where you can use C++.
You can also rename main.c to main.cpp but the next time you run cubemx it will add main.c back as it sees it missing (could be solved in future update). Then you will have two main functions and the compiler will shout at you.
Also I think its much neater to store all mcu peripheral initializations in main.c and use your own vode in "projectMain.cpp".
So, if you want to use a class, define it in a header, maybe implenentation in a .cpp file and use it in projectMain.cpp.. Follow the example repositort on github "stm32-cmake" and "stm32". All C->C++ "communication" has to be done via C style pure functions. Afain thats why I use prokectMain.cpp.
@
Hi Matej!
Thank you once again for your help. Finally, I'm using "projectMain.cpp" file and create my classes in separate files and I can tell them without any problems.
My code compiles and debugs without problems but I have problems with the next warning: cannot open source file "stddef.h" . This message red underline #include "main.h" and #include "stdio.h" statements. Do you know how can I fix it?