Most things in LLVM are created through a static method call instead of directly using a constructor. One reason is that an existing object can be returned instead of creating a new instance.
"Create a FunctionType taking no parameters." A better translation would be: "Create a FunctionType taking no fixed/positional parameters."
After creating the function you get:
After adding the basic block:
After adding the builder, the block and the return statement:
And finally, after installing, compiling, reading docs and tutorials...
I can compile the generated code!!
2> to redirect the stderr to a file.
I redirect stderr because the output generated by our program in done by
mainModule.dump(); and it writes to stderr.
And the output of the last command is... nothing! 🎉 Why is that a reason to celebrate? That's good because without the main function or without the return void statement the output was an execution error.
I cannot check the correct behaviour of the generated code becase I'm not doing anything in our code. Returning and integer to check that the program is working properly will be the next step. See you in the next post!