qpp How do I cheat?
  Reputation: 0
  Joined: 05 Dec 2009 Posts: 2
 
  | 
		
			
				 Posted: Thu May 06, 2010 11:32 am    Post subject: C++/CLI and native code question | 
				       | 
			 
			
				
  | 
			 
			
				Hi,
 
 
I've tested compiling VC++ class library with CLR support (/clr).
 
 
Now, say I have the following function exported:
 
 	  | Code: | 	 		  extern "C" __declspec(dllexport) int Func();
 
 
__declspec(dllexport) int Func()
 
{
 
   return 5;
 
} | 	  
 
 
The PE export table shows the exported function so I'd assume that it's compiled into native code. However, when I look the DLL with IL DASM I see it's compiled into MSIL:
 
 
 	  | Code: | 	 		  . method assembly static int32 modopt([mscorlib]System. Runtime. CompilerServices. CallConvCdecl) 
 
        Func() cil managed
 
{
 
  . vtentry 1 : 1
 
  . export [1] as Func
 
  // Code size       4 (0x4)
 
  . maxstack  1
 
  . locals ([0] int32 V_0)
 
  IL_0000:  ldc. i 4. 5
 
  IL_0001:  stloc. 0
 
  IL_0002:  ldloc. 0
 
  IL_0003:  ret
 
} // end of method 'Global Functions'::Func
 
 | 	  
 
 
Could you help me to understand this behaviour.
 
 
Edit: I applied extra spaces to the MSIL because the idiotic forum software keeps recognizing URLs everywhere (I don't have reputation to post URLs). I couldn't PM mod about this either because of lack of rep!
 | 
			 
		  |