#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
The clang executable is actually a small driver which controls the overall execution of other tools such as the compiler, assembler and linker. Typically you do not need to interact with the driver, but you transparently use it to run the other tools.
gcc and g++ are the traditional GNU compilers for C and C++ code. Recently, clang (and clang++) using LLVM has been gaining popularity as an alternative compiler.
Prerequisites. One of the goals of the Clang project is to be compatible with GCC, in dialect and on the command-line (see #Differences from GCC). Occasionally some packages will fail to build correctly with it and some may build successfully but segfault when executed.
Clang-cl support This means that most developers can use clang-cl to compile their C/C++ applications on Visual Studio/MSBuild on the Windows on Arm device, without needing to change the command line.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With