Where to place namespaces in c++ program

Hey everyone. Maybe I misread some of the documentation, but I cannot seem to find any info on how to write a c++ program for the PLCNext using additional libraries. In a “normal” programming environment, when I write a c++ program, I would simply make the #include at the top of the program.

Immediately below it, I would write the “using namespace” etc. for that library.
I am writing some software using the OpenCV library, which I have tested on a Windows machine, the code has a ‘normal’ lay-out, like this: #include “stdio”
#include “opencv/core/core.hpp” using namespace cv; int main (int argc, char** argv){ //Execution here } However, now that I am ready to use (re-write) this code for an AXCF2152, I can not simply use the “using namespace” syntax, because writing software for this target has to be done inside the library, example: namespace Library { namespace component {
program::program
{
// port info here
} void program::execute(){
//execution here
}
}} How do I go about using the namespaces from an imported library in an AXCF2152 program? I did not have any success adding them in the header file, or I made a mistake doing that… It would be greatly appreceated if anyone has some documentation or tips as to how this is done… Regards,
David.

Hi David, Using namespaces is exactly the same as in regular C++ (as it is regular C++). Given this class ‘Benchmark’ (cpp):

#include "Benchmark.h"
namespace NL_PXC {
namespace UTIL {

using namespace std::chrono;
}
}

for example the verbose way is would be

 NL_PXC::UTIL::Benchmark *bm;// = new Benchmark(5);

the more compact means would be:

#include "../util/Benchmark.h"


namespace NL_PXC { namespace Example_Database {

using namespace Arp;
using namespace Arp::Plc::Esm;
using namespace NL_PXC::UTIL;

class MyDatabaseProgram : public ProgramBase, private Loggable
{
public: // typedefs

public: // construction/destruction
    MyDatabaseProgram(const String& name);
    MyDatabaseProgram(const MyDatabaseProgram& arg) = delete;
    virtual ~MyDatabaseProgram(void) = default;

public: // operators
    MyDatabaseProgram&  operator=(const MyDatabaseProgram& arg) = delete;

public: // properties

public: // operations
    void    Execute(void)override;

private: // fields

   Benchmark *bm;// = new Benchmark(5);

That seems to work just dandy. Thank you. Regards,

David.