【发布时间】:2014-05-30 05:46:30
【问题描述】:
我正在尝试在 LLVM 汇编代码中将字符串转换为整数。该代码在 atoi 上运行良好,但我想切换到 strtol。
这是代码:
; initialise a number
@number0 = private unnamed_addr constant [2 x i8] c"5\00"
%str = getelementptr [2 x i8]* @number0, i64 0, i64 0
; the endpointer that indicates an error
%endptr = alloca i8*
; the actual call of strtol
%addr = getelementptr i8* %str, i64 0
%new_long = call i64 @strtol(i8* %addr, i8** %endptr)
; debug printing
%after_casting = getelementptr [18 x i8]* @after_casting, i64 0, i64 0
call i64(i8*, ...)* @printf(i8* %after_casting, i64 %new_long)
现在,调试 printf 消息打印 0。我猜 endptr 传递有问题。我做错了什么?
【问题讨论】: