hi
im still in the learning process of cpp, todays work is to use namespaces.
the goal: define functions outside of a class, therefore, no object is needed to execute the function.
initial step (tutorial):
main.cpp:
namespace HWLib
{
void Initialize(void);
}
void HWLib::Initialize(void)
{
HAL_Init();
}
int main(void)
{
/* Initialize HWLib */
HWLib::Initialize();
works without any problem.
step 2: move into a separate source and header file:
main.cpp:
#include "HWLib.hpp"
int main(void)
{
/* Initialize HWLib */
HWLib::Initialize();
}
HWLib.hpp
namespace HWLib
{
void Initialize(void);
}
HWLib.cpp
#include "HWLib.hpp"
void HWLib::Initialize(void)
{
HAL_Init();
}
starts with: unknown type name 'namespace' and some other errors indicating missing line endings and brackets.
do you see the error?