Loading...
 

Zephyr project on STM32

   Zephyr Workbench, a VSCode extension to manage Zephyr on STM32.
It enables users to easily create, develop, and debug Zephyr applications.
Main features:
  • Install host dependencies.
  • Import toolchain and SDK.
  • Create, configure, build and manage apps.
  • Debug STM32.
You can directly download it from the VSCode marketplace
For more details, visit the Zephyr Workbench

System Workbench for STM32


sw4stm32 fails to link a cpp header and source file

hi.
i created a project for the stm32l4-discovery board with the system workbench via:
new->cpp project->ac6 executable stm32 mcu project and chose the discovery board.
the workbench already adds both gcc and g++ and has already converted the project
to a c++ project.

now, when i add own classes, i add the path to the header to both compilers
(is this right or just g++?), rename the main.c to main.cpp.
after adding the header of the class to the main file, i try to create a sample
object.

somewhat, the workbench seems to fail linking source and header file of the object.
when i add the source file as include to the main.cpp, it compiles without error.
if i just add the header like normally, the compiler can find only the constructors
prototype in the header but cant see the definition of the constructor in the source file.

what is wrong here?

---------
main.c
---------

  1. include
  2. include // this way it works, without it doesnt


ComPoint Test;

while(1)
{

}

---------
comPoint.hpp
---------
/* Guard symbol ----------------------*/

  1. ifndef COMPOINT_HPP_
  2. define COMPOINT_HPP_


/* Includes ----------------------*/

  1. include “stdint.h”


/* Class definition ----------------------*/
class ComPoint
{
public:
ComPoint(void);
ComPoint(uint8_t initX, uint8_t initY);
~ComPoint(void);

void SetPoint(ComPoint p);
void SetX(uint8_t x);
void SetY(uint8_t y);
uint8_t GetX(void);
uint8_t GetY(void);

private:
uint8_t xCoord;
uint8_t yCoord;
};

  1. endif /* COMPOINT_HPP_ */


---------
comPoint.cpp
---------
/* Includes ----------------------*/

  1. include


/* Object function definitions -------------------*/

// constructor of the object
ComPoint::ComPoint(void)
: xCoord(0), yCoord(0)
{

}

// constructor of the object
ComPoint::ComPoint(uint8_t initX, uint8_t initY)
: xCoord(initX), yCoord(initY)
{

}

// destructor of the object
ComPoint::~ComPoint(void)
{

}

void ComPoint::SetPoint(ComPoint p)
{
xCoord = p.GetX();
yCoord = p.GetY();
}

void ComPoint::SetX(uint8_t x)
{
xCoord = x;
}

void ComPoint::SetY(uint8_t y)
{
yCoord = y;
}

uint8_t ComPoint::GetX(void)
{
return xCoord;
}

uint8_t ComPoint::GetY(void)
{
return yCoord;
}

 

Newest Forum Posts

  1. Монтаж камина с грилем в Москве - установка и барбекю by KpddomErorb, 2025-05-10 18:28
  2. SPI on Nucleo_STMH533RE by royjamil, 2025-05-04 20:13
  3. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-25 07:37
  4. SPI on Nucleo_STMH533RE by royjamil, 2025-03-23 11:31
  5. SPI on Nucleo_STMH533RE by higginsa1, 2025-03-23 09:33
  6. Configuring DMA for ADC in SW? by sam.hodgson, 2025-03-04 12:58
  7. Build a project in "release" mode by info@creosrl.it, 2025-02-20 18:12
  8. Build a project in "release" mode by info@creosrl.it, 2025-02-20 17:05
  9. Build a project in "release" mode by tang, 2025-02-20 10:36
  10. Build a project in "release" mode by info@creosrl.it, 2025-02-19 17:35

Last-Modified Blogs