genericopenlibs/cstdlib/UCRT/WECRT0.CPP
changeset 0 e4d67989cc36
child 49 e5d77a29bdca
equal deleted inserted replaced
-1:000000000000 0:e4d67989cc36
       
     1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // EPOC32 version of crt0.c for pure C programs
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32base.h>
       
    20 #include <estlib.h>
       
    21 #include <stdlib.h>
       
    22 
       
    23 extern "C" int wmain (int argc, wchar_t *argv[], wchar_t *envp[]);
       
    24 
       
    25 extern "C" void exit (int ret);
       
    26 
       
    27 GLDEF_C TInt E32Main()
       
    28 	{     
       
    29 	CTrapCleanup::New();
       
    30 
       
    31 	int argc=0;
       
    32 	wchar_t** argv=0;
       
    33 	wchar_t** envp=0;
       
    34 
       
    35 
       
    36 	__crt0(argc,argv,envp);			// get args & environment from somewhere
       
    37 
       
    38 	int ret=wmain(argc, argv, envp);		// go
       
    39 
       
    40 	// no need to explicitly delete the cleanup stack here as all memory used by
       
    41 	// the process will be released by RProcess::Terminate(), called from inside exit().
       
    42 
       
    43 	exit(ret);				// finish with atexit processing
       
    44 
       
    45 	return(KErrNone);
       
    46 	}
       
    47 
       
    48 
       
    49 #ifdef __GCC32__
       
    50 
       
    51 /* stub function inserted into main() by GCC */
       
    52 #ifdef __MCORE__
       
    53 extern "C" void __main (void) {}
       
    54 #else
       
    55 extern "C" void __gccmain (void) {}
       
    56 #endif
       
    57 
       
    58 /* Default GCC entrypoint */
       
    59 extern "C" TInt _mainCRTStartup (void) 
       
    60     {
       
    61     extern TInt _E32Startup();
       
    62     return _E32Startup();
       
    63     }
       
    64 
       
    65 #endif /* __GCC32__ */