Rootcint and typedefs

Hi,
I am working on Windows XP with root 5.16. I would like to use a CRITICAL_SECTION in a class and cant get it to compile with rootcint. I realize CRITICAL_SECTION is a typedef which eventually ends up in winnt.h

typedef struct _RTL_CRITICAL_SECTION {
    PRTL_CRITICAL_SECTION_DEBUG DebugInfo;

    //
    //  The following three fields control entering and exiting the critical
    //  section for the resource
    //

    LONG LockCount;
    LONG RecursionCount;
    HANDLE OwningThread;        // from the thread's ClientId->UniqueThread
    HANDLE LockSemaphore;
    ULONG_PTR SpinCount;        // force size on 64-bit systems when packed
} RTL_CRITICAL_SECTION, *PRTL_CRITICAL_SECTION;

I am not sure how I should modify my Linkdef.h to make my Worker class compile.

My Linkdef.h file is

#ifdef __CINT__

#pragma link off all globals; 
#pragma link off all classes; 
#pragma link off all functions; 

#pragma link C++ class Worker; 

#endif 
// -- Worker.h

#ifndef SAW_CORRELATION_WORKER
#define SAW_CORRELATION_WORKER

#include <windows.h>

class Worker
{
public:
    // Construction
    Worker() {};
    virtual ~Worker() {}

    // Operations
    static void act();

private:

    // Data
    CRITICAL_SECTION m_criticalSection;
};

#endif
// --Worker.cpp

#include "Worker.h"
#include <iostream>

void 
Worker::act()
{
    std::cout << "I am here\n";
        
}

At present when I run I get:

C:\QVCS\dev\root\work\utils\test1>rootcint -f WorkerDict.cxx -c -p Worker.h Link
Def.h
2102415_cint.cxx
Error: Symbol CRITICAL_SECTIONm_criticalSection is not defined in current scope
 .\worker.h(19)
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing WorkerDict.cxx WorkerDict.h !!!
Error: rootcint: error loading headers...

C:\QVCS\dev\root\work\utils\test1>

Thanks,
Sanjeev
Worker.cpp (136 Bytes)
Worker.h (326 Bytes)
LinkDef.h (163 Bytes)

Hi,

what CINT needs of that CRITICAL_SECTION is really only its size - other than that it’s fine if it stays opaque to CINT: it doesn’t need to know what’s inside. So what you could do is find out the sizeof(CRITICAL_SECTION) (say it’s 42 bytes) and add #ifdef __CINT__ typedef char[42] CRITICAL_SECTION; #endif
That way, CINT will have its own idea of what a CRITICAL_SECTION is which will at least be correct size-wise, so you can e.g. copy Worker objects around.

Axel.

Hi,
Thanks thats good information. Since its only an issue of size I will use a pointer to another class which has all the window specific structs in it.
-Sanjeev