[LLVMdev] Easy way to get value given by user

Byungchan An lionheart8470 at gmail.com
Fri Apr 18 11:14:05 PDT 2014


Hello. I'm a newbie for LLVM.
I have a question on getting input value given by the user.
What I want to get is main's argv's last argument and convert it as integer
value.

I solved this by writing extra function and combining the original program.
To make it work, I also linked with llvm-link command.

The following is the function I linked.

int countconverter(int argc, char** ip) {
    printf("----------Input converter----------\n");
    printf("The input to this program is argc: %d -->
argv[argc-1]%s\n",argc, ip[argc-1]);
    int result = atoi(ip[argc-1]);
    printf("Converted integer is %d\n", result);
    return result;
}

So, whenever I need the value given by the user, I call the function and
store the result in the stack. However, I think it is inefficient.

I believe there is a way to get a value when doing pass in main function
and get the last argument and convert it to integer value. By doing this, I
think I can remove the need for calling function which is good. Can anyone
help me to figure out this problem?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140418/82cb535b/attachment.html>


More information about the llvm-dev mailing list