鎴戠殑鍏ㄦ爤涔嬭矾-C璇█鍩虹涔婥绋嬪簭杩愯娴佺▼
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了鎴戠殑鍏ㄦ爤涔嬭矾-C璇█鍩虹涔婥绋嬪簭杩愯娴佺▼相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/ini' title='ini'>ini width float push pac gcc author cal 12px
鎴戠殑鍏ㄦ爤涔嬭矾-C璇█鍩虹涔婥绋嬪簭杩愯娴佺▼
4.1 C绋嬪簭鐨勮繍琛屾祦绋?/span>
C璇█缂栧啓鐨勭▼搴忎竴鑸兘瑕佺粡杩囩紪鍐欐簮鏂囦欢->棰勫鐞?>缂栬瘧->姹囩紪->閾炬帴鍚庤繍琛岃繖鍑犱釜娴佺▼銆?br>
- 棰勫鐞?br> 棰勫鐞嗕富瑕佹槸瀹忔浛鎹€佸寘鍚ご鏂囦欢銆佹潯浠剁紪璇戜互鍙婂垹闄ゆ敞閲婄瓑鎿嶄綔锛岄缂栬瘧闃舵鐢熸垚鏂囦欢鐨勫悗缂€鍚嶉€氬父鏄?i銆?/li>
- 缂栬瘧
缂栬瘧涓昏鏄皢棰勫鐞嗗ソ鐨勬枃浠剁敓鎴愭眹缂栨枃浠讹紝缂栬瘧鍚庢枃浠剁殑鍚庣紑鍚嶉€氬父鏄?s銆?/li> - 姹囩紪
姹囩紪涓昏鏄皢姹囩紪鏂囦欢鐢熸垚浜岃繘鍒舵枃浠讹紝姹囩紪鍚庣殑鏂囦欢鐨勫悗缂€鍚嶉€氬父鏄?o銆?/li> - 閾炬帴
閾炬帴涓昏鏄皢鍚勪釜浜岃繘鍒舵枃浠躲€佸簱鍑芥暟銆佸惎鍔ㄤ唬鐮佺敓鎴愬彲鎵ц鏂囦欢銆?/li>
鎺ヤ笅鏉ョ紪鍐欐簮绋嬪簭program_running_process.c,鐒跺悗缁撳悎Windows涓婄殑GCC缂栬瘧鍣ㄦ彁渚涚殑鍚勪釜閫夐」瀹炵幇棰勫鐞嗐€佺紪璇戙€佹眹缂栥€侀摼鎺ワ紝鍏充簬GCC鐨勫畨瑁呭拰閰嶇疆鍙互鍙傝€?br> Visual Studio Code瀹炵幇Hello World绔犺妭鐨勫唴瀹广€?/p>
#include <stdio.h>
//瀹氫箟娴偣鍨嬬殑甯搁噺
#define PI 3.14
/*
C璇█绋嬪簭鐨勮繍琛屾祦绋? @author tony ittimelinedotnet@gmail.com
@version 2019/08/20
*/
int main(int argc, char* argv[])
printf("PI =%lf\n", PI);
return 0;
棰勫鐞嗕娇鐢?gcc -E 閫夐」鍗冲彲瀹炵幇锛屽叾涓?o琛ㄧず杈撳嚭鏂囦欢鐨勫悕绉?/p>
D:\workspace\c\visualstuido2019\c-core-programming\c-core-programming-foundational\c-core-programming-foundational>gcc -E program_runing_process.c -o program_runing_process.i
棰勫鐞嗗畬鎴愪互鍚庯紝鐢熸垚鐨勬枃浠秔rogram_running_process.i鐨勫ぇ灏忔槸54kb
褰撻澶勭悊瀹屾垚浠ュ悗锛屽畾涔夌殑甯搁噺琚浛鎹㈡垚瀹為檯鐨勫€硷紝鑰?include鍖呭惈鐨勫ご鏂囦欢鍐呭涔熻澶嶅埗鍒伴澶勭悊鐨勭敓鎴愮殑鏂囦欢涓?br>
缂栬瘧閫氳繃gcc -S 閫夐」瀹炵幇
D:\workspace\c\visualstuido2019\c-core-programming\c-core-programming-foundational\c-core-programming-foundational>gcc -S program_runing_process.i -o program_runing_process.s
缂栬瘧浼氱敓鎴愭眹缂栨枃浠?/p>
.file "program_runing_process.c"
.text
.def __main; .scl 2; .type 32; .endef
.section .rdata,"dr"
.LC1:
.ascii "PI =%lf\12\0"
.text
.globl main
.def main; .scl 2; .type 32; .endef
.seh_proc main
main:
pushq %rbp
.seh_pushreg %rbp
movq %rsp, %rbp
.seh_setframe %rbp, 0
subq $32, %rsp
.seh_stackalloc 32
.seh_endprologue
movl %ecx, 16(%rbp)
movq %rdx, 24(%rbp)
call __main
movq .LC0(%rip), %rax
movq %rax, %rdx
movq %rdx, %xmm1
movq %rax, %rdx
leaq .LC1(%rip), %rcx
call printf
movl $0, %eax
addq $32, %rsp
popq %rbp
ret
.seh_endproc
.section .rdata,"dr"
.align 8
.LC0:
.long 1374389535
.long 1074339512
.ident "GCC: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0"
.def printf; .scl 2; .type 32; .endef
姹囩紪閫氳繃gcc -c 閫夐」瀹炵幇
D:\workspace\c\visualstuido2019\c-core-programming\c-core-programming-foundational\c-core-programming-foundational>gcc -c program_runing_process.s -o program_runing_process.o
閾炬帴gcc娌℃湁鎻愪緵閫夐」锛岃繖閲屽彧瑕佹墽琛実cc program_running_process.o -o program_running_process.exe灏变細閾炬帴鐢熸垚鍙墽琛屾枃浠?/p>
D:\workspace\c\visualstuido2019\c-core-programming\c-core-programming-foundational\c-core-programming-foundational>gcc program_runing_process.o -o program_runing_process.exe
windows涓嬬殑鍙墽琛屾枃浠跺悗缂€鍚嶉粯璁ゆ槸.exe锛屽綋鐒秅cc缂栬瘧鍣ㄤ笉鍏冲績鍚庣紑鍚嶏紝濡傛灉浣犵殑ubuntu鎴栬€卪acOS涓嬪畨瑁呬簡gcc,涔熷彲浠ュ皢C绋嬪簭缂栬瘧鐢熸垚.exe鍚庣紑鐨勫彲鎵ц鏂囦欢銆?/p>
以上是关于鎴戠殑鍏ㄦ爤涔嬭矾-C璇█鍩虹涔婥绋嬪簭杩愯娴佺▼的主要内容,如果未能解决你的问题,请参考以下文章
銆愬涔燙++ 鏁欑▼銆戜簩銆丆++鍩虹璇硶銆佹敞閲婂拰鍙橀噺
杩愯绋嬪簭鏃舵姤go: cannot find main module, but found .git/config in
Anaconda涓畨瑁呬簡Libtiff妯″潡锛屼絾杩愯绋嬪簭鏄剧ずModuleNotFoundError: No module named 'libtiff'