Reputation: 4726
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
using namespace std;
class Book{
public:
int a;
int b;
};
int main()
{
Book b1;
b1.a = 10;
b1.b = 20;
cout<< b1.a << " " <<b1.b;
}
when we compile the above code with
clang++ test.cc -o a.exe
and run a.exe works perfectly. But when we compile the same program with
clang++ test.cc -emit-llvm -S -o a.exe
and now when we run it, the program goes crazy by launching ntvdm.exe
(can be seen in process explorer) and command prompt starts behaving weird.
Software stack:
clang version 2.9 (tags/RELEASE_29/final)
Target: i386-pc-mingw32
Thread model: posix
Upvotes: 5
Views: 277
Reputation: 32736
By adding '-emit-llvm -S' you are not generating machine code, but LLVM bytecode. To run that, you need to use lli.
As ntvdm.exe
is virtual machine for running real-mode DOS programs, it might mean that windows interprets executable in LLVM bytecode as 16-bit DOS program and tries to run it as one.
Upvotes: 9