Q:

How do I make main a friend of my class from within a library?

Please see my first attempt at answering this
. I neglected to tell the whole story before in an attempt to simplify things. Turns out my example works! Sorry.
The whole story is that this is a library the contains a class in one file and the main in another file, all linked into my library. The library is providing the basis for a Process Framework, which is why the main is in the library and not the process.
Below is a stripped down version of what I have.
pf.hpp
using namespace std;

namespace MyNamespace
{
  class ProcessManager
  {
  public:
    friend int main(int argc, char** argv);
  private:
    void test();
  };
};

pf.cpp
#include "pf.h"

namespace MyNamespace
{
  ProcessManager::test()
  {
    cout << "My friend has accessed my member" << endl;
  }
};

pfmain.cpp
#include "pf.hpp"

int main(int argc, char** argv)
{
   ProcessManager pm;

   pm.test();
}

Note that this fails on the compilation of the library
What I have tried is:

Moving the friend all over the place
Making the friend reference to main use global scope (e.g. ::main)
Making friend and main declarations use global scope

What am I missing?
Thanks!

A:

Just declare the main outside the MyNamespace and specify global namespace :: in friend statement
//in header file of ProcessManager
//your pf.h

int main(int argc, char** argv);

namespace MyNamespace
{
  class ProcessManager
  {
  public:
    friend int ::main(int argc, char** argv);
  private:
    void test();
  };
};

