Is there not a C++ compiler for CodeDOM?

D

DSP56k

Using the CodeDomExample

http://msdn.microsoft.com/library/d...mcodedomcompilercodedomproviderclasstopic.asp

I added support for C++. The example will generate the C++ code
listing using the MCppCodeProvider OK, but when it comes to the
statement:

ICodeCompiler compiler = provider.CreateCompiler();

it returns null and so it can't compile the C++ listing.

Is there not a C++ compiler for Codedom?

Here are my additions to the CodedomExample which fail me.


namespace CodeDOMExample
{

using Microsoft.MCpp;
// ADDED namespace

public CodeDomExampleForm()
{
....
this.comboBox1.Items.AddRange( new string[] { "CSharp",
"Visual Basic", "JScript", "C++" } ); // ADDED "C++" item
....
}

private CodeDomProvider GetCurrentProvider()
{
...
case "C++": provider = new MCppCodeProvider();
// ADDED MCppCodeProvider to case statement
break;
...
}
return provider;
}

public static CompilerResults CompileCode( CodeDomProvider
provider, String sourceFile, String exeFile )
{
ICodeCompiler compiler = provider.CreateCompiler();
// PROBLEM, returns null for CreateCompiler() when provider == new
MCppCodeProvider();
String [] referenceAssemblies = {"System.dll"};
CompilerParameters cp =
new CompilerParameters(referenceAssemblies, exeFile,
false);
cp.GenerateExecutable = true;
CompilerResults cr = compiler.CompileAssemblyFromFile
(cp, sourceFile); // ERROR, compiler ==
null
return cr;
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top