Why the Pre header compilations do not run from the execute command in WM? The code run smoothly in Visual Studio 2017. It runs fine when commenting out the #include \"pch.h\" . But this will reader dead most of my C++ work.
Needs["CCompilerDriver`"]
CCompilers[]
hello = CreateExecutable["
// ConsoleApplication5.cpp : Defines the entry point for the \
console application.
//
#include \"pch.h\"
#include <iostream>;
using namespace std;
int main()
{
int numbers[5];
int * p;
p = numbers; *p = 10;
p++; *p = 20;
p = &numbers[2]; *p = 30;
p = numbers + 3; *p = 40;
p = numbers; *(p + 4) = 50;
for (int n = 0; n < 5; n++)
cout << numbers[n] << \" , \" ;
return 0;
}
", "hellomyfirst", Language -> "C++",
"Compiler" ->
CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
"CompilerInstallation" ->
"C:\\Program Files (x86)\\Microsoft Visual \
Studio\\2017\\Community", "CompilerName" -> Automatic
]
Import["!" <> QuoteFile[hello], "Text"]
But the run fails
Out[138]= {{"Name" -> "Visual Studio",
"Compiler" ->
CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
"CompilerInstallation" ->
"C:\\Program Files (x86)\\Microsoft Visual \
Studio\\2017\\Community",
"CompilerName" -> Automatic}, {"Name" -> "Visual Studio",
"Compiler" ->
CCompilerDriver`VisualStudioCompiler`VisualStudioCompiler,
"CompilerInstallation" ->
"C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\",
"CompilerName" -> Automatic}}
During evaluation of In[137]:= CreateExecutable::cmperr: Compile error: C:\Users\jecalderon\AppData\Roaming\Mathematica\SystemFiles\LibraryResources\Windows-x86-64\Working-desktop-jvm8477-5036-12984-15\hellomyfirst.c(4): fatal error C1083: Cannot open include file: 'pch.h': No such file or directory
Out[139]= $Failed
During evaluation of In[137]:= StringJoin::string: String expected at position 2 in !<>QuoteFile[$Failed].
During evaluation of In[137]:= Import::chtype: First argument !<>QuoteFile[$Failed] is not a valid file, directory, or URL specification.
Out[140]= $Failed