Created
October 19, 2014 18:03
-
-
Save andrewrk/1558b3a1c4dd1c130bbf to your computer and use it in GitHub Desktop.
clang -o test test.c -I/usr/lib/llvm-3.5/include -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -lLLVM-3.5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "llvm-c/Core.h" | |
int main(int argc, char *argv[]) { | |
LLVMBuilderRef builder = LLVMCreateBuilder(); | |
LLVMModuleRef module = LLVMModuleCreateWithName("main_module"); | |
LLVMTypeRef main_type = LLVMFunctionType(LLVMVoidType(), NULL, 0, 0); | |
LLVMValueRef main_fn = LLVMAddFunction(module, "main", main_type); | |
LLVMSetFunctionCallConv(main_fn, LLVMCCallConv); | |
char *module_string = LLVMPrintModuleToString(module); | |
puts(module_string); | |
LLVMDisposeMessage(module_string); | |
LLVMDisposeModule(module); | |
LLVMDisposeBuilder(builder); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment