Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » lerning namespaces (cpp)
lerning namespaces (cpp) [message #1741719] Sun, 28 August 2016 19:44 Go to next message
luu tecFriend
Messages: 11
Registered: August 2016
Junior Member
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?
Re: lerning namespaces (cpp) [message #1741724 is a reply to message #1741719] Sun, 28 August 2016 23:38 Go to previous message
luu tecFriend
Messages: 11
Registered: August 2016
Junior Member
CLOSED! Solution: Since it is a c/cpp project, somehow the gcc compiler was used for the namespace compilation instead of the g++.
Previous Topic:Exported Runable jar Problem
Next Topic:Side scroll in Logitech MX Master
Goto Forum:
  


Current Time: Thu Apr 25 20:42:01 GMT 2024

Powered by FUDForum. Page generated in 0.08108 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top