Mixing Mananged and Unmanaged in an Unmanaged class

From: Jon (jon_at_martinsound.com)
Date: 05/24/04


Date: Mon, 24 May 2004 15:49:23 -0700

Whether I can compile a class or not, depends on the order of functions in my class.

My question is (see example below):
  1) Is it a bug that the class 'WillCompile' will compile and execute, or
  2) or is it a bug that the class 'WillNotCompile' will not compile?.

#include "stdafx.h"
#include <iostream>
#include <memory>
using namespace std;

#using <mscorlib.dll>

using namespace System;

#pragma unmanaged
class WillCompile {
public:
    static void Umg() {
    }
    #pragma managed
    static void Mng( String* str ) {
        Console::WriteLine( str );
    }
};

#pragma unmanaged
class WillNotCompile {
public:
    #pragma managed
    static void Mng( String* str ) {
        Console::WriteLine( str );
    }
    #pragma unmanaged
    static void Umg() {
    }
};

#pragma managed
int _tmain()
{
    WillCompile::Mng( S"This works." );

    Console::WriteLine(S"Press Enter to continue.");
    Console::ReadLine();
 return 0;
}



Relevant Pages

  • Re: Compiler Warning
    ... string. ... When I compile this ... char* xstrip(const char* str) ...
    (comp.lang.c)
  • Re: Debug Vs Release
    ... > If I compile that code in debug mode then dissassemble the EXE, ... > private static void Main(stringargs) ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: string concantenation problem.
    ... while if i compile it to an exe and run it i get str as "0000,, ... Dim stra As String ... Private Sub Command1_Click ...
    (microsoft.public.vb.general.discussion)
  • Re: struct ToString() not automatically invoked
    ... struct to string does not implicitly take place. ... public struct MyStruct ... static void Main ... Print; // doesn't compile ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Compiler Warning
    ... string. ... When I compile this ... char* xstrip(const char* str) ...
    (comp.lang.c)