我正在学习FreeBSD上的汇编语言编程.我正在使用FreeBSD 9.0 i386发行版和nasm汇编程序.
当我编写一个简单的系统调用函数时,我发现我必须将无用的值推入堆栈以使代码正确运行.
例如:
; File:test.asm
section .text
global _start
_start:
xor eax,eax
; Argument of exit()
push 0x0
; Syscall of exit()
mov al,1
int 0x80
Run Code Online (Sandbox Code Playgroud)
我使用以下命令来汇编和链接上面的代码:
%nasm -f elf test.asm -o test.o
%ld test.o -o test.bin
Run Code Online (Sandbox Code Playgroud)
我用ktrace来检查程序,发现:
%ktrace ./test.bin
%kdump -d -f ./ktrace.out
2059 ktrace RET ktrace 0
2059 ktrace CALL execve(-1077940941,-1077941260,-1077941252)
2059 ktrace NAMI "./test.bin"
2059 test.bin RET execve 0
2059 test.bin CALL exit(1)
Run Code Online (Sandbox Code Playgroud)
所以代码没有正确运行,因为我提供了0作为exit()的唯一参数,但程序实际上运行了exit(1).
然后我改变了我的代码.
; File:test.asm
section .text
global _start
_start:
xor eax,eax
push …Run Code Online (Sandbox Code Playgroud) 我使用pdflatex生成pdf文件。由于非英语字符,我的源文件都是utf-8编码的。没有\usepackage{hyperref}代码,就可以毫无问题地进行编译。但是当我把\usepackage{hyperref}(甚至没有任何\href{}{}代码)放在包装清单中时,会出现一个错误,说
**************************************
! Use of \@chapter doesn't match its definition.
\CJK@altchar ...fx \csname \reserved@a \endcsname
\relax \CJKsymbol {\@tempc...
l.1 \chapter{XXX}
?
**************************************
Run Code Online (Sandbox Code Playgroud)
其中“ XXX”代表非英语字符。
然后我在Google上搜索了很多,发现原因是hyperref使用pdftex驱动程序,该驱动程序不适用于utf-8编码的文件。我检查了以下页面:http : //www.tug.org/applications/hyperref/manual.html,但是找不到适合pdflatex的驱动程序。
我尝试过\usepackage[utf8]{inputenc},但仍然无法正常工作。
有人可以帮我吗?谢谢!
我在项目中使用了“all_load”和“noall_load”ld 标志,但编译器/ld 报告 noall_load 被忽略。它的替代品是什么?
$ cc ... -Wl,-all_load lib1 -Wl,-noall_load lib2 lib3 ...
...
ld: warning: option -noall_load is obsolete and being ignored
...
$ ld -v
@(#)PROGRAM:ld PROJECT:ld64-253.3
configured to support archs: armv6 armv7 armv7s arm64 i386 x86_64 x86_64h armv6m armv7k armv7m armv7em
LTO support using: Apple LLVM 7.0.0 (clang-700.0.72)
Run Code Online (Sandbox Code Playgroud) #include "stdio.h"
#define COUNT(a) (sizeof(a) / sizeof(*(a)))
void test(int b[]) {
printf("2, count:%d\n", COUNT(b));
}
int main(void) {
int a[] = { 1,2,3 };
printf("1, count:%d\n", COUNT(a));
test(a);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
结果很明显:
1, count:3
2, count:1
Run Code Online (Sandbox Code Playgroud)
我的问题:
例如,strrev()函数.我知道它是在string.h中声明的,我想知道它是如何实现的.那我的源代码在哪里?
操作系统:Windows XP SP3
IDE:Pelles C 6.50 RC3
这是示例代码:
public static BaseListAdapter<? extends Item> getListAdapter() {
...
}
...
public class MyClass<T extends Item> {
...
BaseListAdapter<T> adapter = (BaseListAdapter<T>) getListAdapter();
...
}
Run Code Online (Sandbox Code Playgroud)
编译器抱怨有一个未经检查的强制转换.
java: unchecked cast
need: BaseListAdapter<T>
found: BaseListAdapter<capture#1, ? extends Item>
Run Code Online (Sandbox Code Playgroud)
我想知道为什么会产生这个警告以及如何解决它.