ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

PA Note

2022-08-14 09:30:45  阅读:245  来源: 互联网

标签:gcc ## filename Note start PA line hello


PA Note

Linux

#
$sudo apt update


# 
$whereis <name>

Vim

0 line start, $ line end

/word search "word", n find next, N find previous

d0 delete until line start, d$ delete until line end, dd cut current line

y0 copy until line start, y$ copy until line end, yy copy current line

p paste register

u undo, ctrl+r redo

gcc

## ref

# https://www.cprogramming.com/gcc.html
# https://www3.ntu.edu.sg/home/ehchua/programming/cpp/gcc_make.html


## Syntax

#
-o outputfile
# enable all warnings
-Wall
# treat warnings as errors
-Werror
# to use by gdb
-g


## Process

# 1.pre-processing
# include headers and expands the macros
$cpp hello.c > hello.i
# 2.compilation
# compile into assembly code for a specific processor
$gcc -S hello.i
# 3.assembly
# convert into machine code
$as -o hello.o hello.s
# 4.linker
$ld -o hello hello.o ...libraries...


## Utilities

# display the type of object files and executable files 
$file <filename>
# lists symbol table of object files
$nm <filename>
# examines an executable and displays a list of the shared libraries that it needs
$ldd <filename>

make

a makefile for hello.c

all: hello

hello: hello.o
	gcc -o hello hello.o

hello.o: hello.c
	gcc -c hello.c

clean:	
	rm hello.o hello

rules

target: pre-req-1 pre-req-2
    command

Run the command if the target is out-dated compared with its pre-requisite.

Note that command must be preceded by a tab.

Note that start the target "all" when running make without argument.

Another version:

# define a macro
filename = hello
all:    $(filename)
    echo ALL DONE

$(filename):    $(filename).o
    gcc -o $(filename) $(filename).o

# $@ for the pattern-matched target
# $< for the pattern-matched dependency
%.o:    %.c
    gcc -o $@ -c $<

clean:
    rm *.o $(filename)

gdb

ref

# start
$gdb <executable name>

# show lines
$list
# set breakpoints
$break <source code line number>
# print variable
$print <var name to print>
# set variable's values
$set <var> = <value>
# watch a variable and pause when it is changed
$watch <var>

# run
$run
# continue
$continue
# hit <return> re-executes the last command
$<return>
# qiut
$quit

标签:gcc,##,filename,Note,start,PA,line,hello
来源: https://www.cnblogs.com/santiego/p/16584805.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有