2009-01-26 04:57 AM
Conversion of the Project to C++
2011-05-17 04:00 AM
Hello,
I am writing a firmware for STM32F10x microcontroller. I try to convert my project to C++. When I build the project, the compiler gives me the following warning message in file stm32f10x_vetor.c: warning: variable ''__vector_table'' was declared but never referenced. Please help. Thanks in advance.2011-05-17 04:00 AM
Quote:
warning: variable ''__vector_table'' was declared but never referenced.
So remove the declaration!2011-05-17 04:00 AM
It will not solve the problem.
I need the vector table in flash memory in order to be able to handle the interrupts. :-?2011-05-17 04:00 AM
Quote:
It will not solve the problem.
It will solve the problem that you stated; viz, the ''declared but not used'' compiler warning.Quote:
I need the vector table in flash memory in order to be able to handle the interrupts
So the real problem is, ''How to specify the interrupt vectors in C++''You could, of course, just avoid that problem by sticking with 'C'... 8-) Why do you specifically want to convert an existing application to C++ ?? I can understand starting a new one in C++ - but why convert an existing one?! :-?2011-05-17 04:00 AM
Quote:
On 22-01-2009 at 13:29, Anonymous wrote:Quote:
It will not solve the problem.
It will solve the problem that you stated; viz, the ''declared but not used'' compiler warning.Quote:
I need the vector table in flash memory in order to be able to handle the interrupts
So the real problem is, ''How to specify the interrupt vectors in C++'' You could, of course, just avoid that problem by sticking with 'C'... 8-) Why do you specifically want to convert an existing application to C++ ?? I can understand starting a new one in C++ - but why convert an existing one?! :-? It is actually a new program. I would like to use IAR Firmware Library, which is written in C and to add my own code which will be, as I hope, written in C++. C++ is much more modular and convinient language, for my opinion. I understand that you know English better than me, however, I think that it is not the main issue. If you know the solution, please help.2011-05-17 04:00 AM
Hi,
we just left the file stm32f10x_vetor.c as it is. We only changed the definitions of the interrupt functions in the file stm32f10x_it.c to extern ''C'' and the file itself to stm32f10x_it.cpp. This works for us. An other solution could be to define the vector table as volatile: volatile const intvec_elem __vector_table[] = But in my opinion it is best not change the whole library to c++. It is best to use it with extern ''C'' in your c++ App.2011-05-17 04:00 AM
Thank you very much for your reply, Peter.
I tried to put the definitions of the functions in file stm32f10x_it.c to Extern ''C'' block. Then I've changed the name of the file to stm32f10x_it.cpp. Compiler enforced me also to put the function declarations in ''stm32f10x_it.h'' file into Extern ''C'' block. When I did it, the compiler still gave me the same warning message : Warning[Pe177]: variable ''__vector_table'' was declared but never referenced :-[ . I did not touch stm32f10x_vector.c, as you said. May be there is something else you did in your project?2011-05-17 04:00 AM
Quote:
Then I've changed the name of the file to stm32f10x_it.cpp.
That's probably a bad idea: The compiler may well assume that the .cpp extension means that the file has to be compiled as C++Quote:
I did not touch stm32f10x_vector.c
Yes you did - you changed its name! It really sounds like you are fighting too many unknowns here: Wouldn't you find it easier to start in 'C' until you are fully familiar with how everything hangs together, then move on to C++ (if you still feel the need) once you've laid some solid foundations?