[aspectc-user] (no subject)

Matthias.Ritter at metop.de Matthias.Ritter at metop.de
Thu Mar 12 08:12:28 CET 2009


Unfortunatly it still doesn't work.
Of course my first try was with "WINAPI", that changes nothing.
I reduced my code on a minimum and it looks like that:

The Main-function:

int main( void )
{
        Sleep( 1000 );
        cout << "in main function" << endl;
        getchar();
        return 0;
}

my aspect:

aspect foo
{
                HANDLE myThread;
                int ThreadArgs;
                int myThreadId;
                pointcut Main() = execution("% main(...)");

                DWORD WINAPI bar(void* param)
                {
                        cout << "in Thread-Function" << endl;
                        return 0;
                }

                advice Main() : before()
                {
                        cout << "aspect before main" << endl;
                        myThread = CreateThread( NULL, 0, bar, (void
*)&ThreadArgs, 0, (LPDWORD)&myThreadId );
                }

                advice  Main() : after()
                {
                        cout << "aspect after Main" << endl;
                        TerminateThread (myThread, 0);
                        CloseHandle(myThread);
                }
};

I tried the 3 lines "CreateThread", "TerminateThread" and "CloseHandle" in 
an own main without weaving an aspect, and it works.
Without the "CreateThread" call the aspect works fine.



###################################################################################################

On 10.03.2009, at 11:01, Matthias.Ritter at metop.de wrote:


Hello, 

I'm programming an analysing tool for c++ code. 
I'm using the AspectC++ Add-In for Visual Studio .NET (2003). 
I tried to weave a thread into the application, starting before the 
main-function is executed. 
The code looks like this: 

DWORD bar(void* param) 
                { 
                        // do something 
                        return 0; 
                } 

AFAIK the prototype of thread start functions has to be

DWORD WINAPI bar(void* param);

The WINAPI macro expands to __stdcall, which is a relevant part of the 
function's signature.

Daniel 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.aspectc.org/pipermail/aspectc-user/attachments/20090312/f93d6af1/attachment.html>


More information about the aspectc-user mailing list