Hi Rostfrei, One way of doing this is to create a dummy counting class and just create instances of it. Hence this becomes:
countcpp.h:
#ifndef __COUNT_H__
#define __COUNT_H__
#include <iostream.h>
#define REGISTER_MODULE(file,des) static CCountCpp g_cppFile (file, des);
class CCountCpp
{
public:
CCountCpp (void) { }
CCountCpp (const char *strFile, const char *strDes)
{
cout << strFile << "{ " << strDes << " }" << endl;
++m_iCppCount;
}
static int m_iCppCount;
};
#endif // __COUNT_H__
This just creates a static CCountCpp object per REGISTER_MODULE define. Because of the static objects they can be the same name across modules as long as you are not including .cpp files. To use:
#include "countcpp.h"
REGISTER_MODULE(__FILE__, "disk writer");
int CCountCpp::m_iCppCount = 0;
void main (void)
{
CCountCpp c;
cout << "Cpp count: " << c.m_iCppCount << endl;
}
Naturally you would remove the main, it is just there for show. regards, Rich "Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far the Universe is winning." -- Rich Cook