从C到装配

leg*_*o69 4 c eclipse assembly

我如何从C程序中获取汇编代码我使用了这个建议 ,我-c -fmessage-length=0 -O2 -S在Eclipse中使用了类似的东西,但是我有一个错误,提前感谢任何帮助

现在我有这个错误

   atam.c:11: error: conflicting types for 'select'
/usr/include/sys/select.h:112: error: previous declaration of 'select' was here
atam.c:11: error: conflicting types for 'select'
/usr/include/sys/select.h:112: error: previous declaration of 'select' was here
Run Code Online (Sandbox Code Playgroud)

这是我的功能

int select(int board[],int length,int search){
    int left=0, right=length-1;

    while(1){
        int pivot_index=(right+left)/2;
        int ordered_pivot=partition(board,left,right,pivot_index);

        if(ordered_pivot==search){
            return board[ordered_pivot];
        }
        else if(search<ordered_pivot){
            right=ordered_pivot-1;
        }
        else{
            left=ordered_pivot+1;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

Mic*_*zek 5

Eclipse仍然将输出视为目标文件

gcc -O0 -g3 -Wall -c -fmessage-length=0 -O2 -S -oatam.o ..\atam.c
Run Code Online (Sandbox Code Playgroud)

正在生成你想要的程序集,但atam.o由于-oatam.o传递给GCC 而导致混淆存储(通常你会将程序集存储在其中atam.s).下一个命令:

gcc -oatam.exe atam.o
Run Code Online (Sandbox Code Playgroud)

尝试链接atam.o并生成可执行文件,但atam.o它是程序集源,而不是目标文件,因此链接器失败.你需要告诉eclipse不要运行第二个命令(你可能想要改变第一个的输出文件名)