๐Ÿ“– Coding Study

2023.03.10 ๊ธˆ (๋ฆฌ๋ˆ…์Šค ๋ช…๋ น์–ด, ๋น„์ฃผ์–ผ ์ŠคํŠœ๋””์˜ค ์ฝ”๋“œ ์ดˆ๊ธฐ ์„ค์ •๋ฒ• ๋“ฑ)

๊ณต๋ถ€๋ชปํ•จ 2023. 3. 11. 15:07

๋ฆฌ๋ˆ…์Šค์˜ ๋ช…๋ น์–ด๋“ค

ls - ํ˜„์žฌ ํด๋”๋‚ด ํŒŒ์ผ๊ณผ ํด๋”๋ฅผ ํ‘œ์‹œํ•ด์คŒ

pwd - ํ˜„์žฌ ๊ฒฝ๋กœ๋ฅผ ํ‘œ์‹œํ•ด์คŒ

clear - ์ง€์šฐ๊ฐœ

cd ํด๋”๋ช… - ํด๋”๋ช… ํด๋”๋กœ ๊ฒฝ๋กœ ์ด๋™

cd ~/ - ์ตœ์ƒ์œ„ ํด๋”๋กœ ์ด๋™

code ํด๋”๋ช… - ํด๋”๋ช…์„ ์ž‘์—… ํด๋”๋กœ ํ•˜๋Š” vs code ์‹คํ–‰

./ํŒŒ์ผ๋ช… - ํŒŒ์ผ๋ช…์˜ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰์‹œ์ผœ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์—ฌ์คŒ

code . - ํ˜„์žฌ ๊ฒฝ๋กœ์˜ ํด๋”๋ฅผ ์ž‘์—… ํด๋”๋กœ ํ•˜๋Š” vs code ์‹คํ–‰

mkdir ํด๋”๋ช… - ํด๋”๋ช…์˜ ํด๋” ์ƒ์„ฑ

 

 

๋น„์ฃผ์–ผ ์ŠคํŠœ๋””์˜ค ์ฝ”๋“œ ์ดˆ๊ธฐ ์„ค์ •

๋น„์ฃผ์–ผ ์ŠคํŠœ๋””์˜ค ์ฝ”๋“œ ์‹คํ–‰ - Terminal - Configure Default Build Task... - C/C++ gcc build active file์„ ํด๋ฆญํ•˜๋ฉด

tasks.json์ด๋ผ๋Š” ํŒŒ์ผ์ด ์ƒ์„ฑ๋œ๋‹ค.

{
	"version": "2.0.0",
	"tasks": [
		{
			"type": "cppbuild",
			"label": "C/C++: gcc build active file",
			"command": "/usr/bin/gcc",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}/${fileBasenameNoExtension}"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": "build",
			"detail": "compiler: /usr/bin/gcc"
		},
		{
			"type": "cppbuild",
			"label": "C/C++: gcc build active file",
			"command": "/usr/bin/gcc",
			"args": [
				"-fdiagnostics-color=always",
				"-g",
				"${file}",
				"-o",
				"${fileDirname}/${fileBasenameNoExtension}"
			],
			"options": {
				"cwd": "${fileDirname}"
			},
			"problemMatcher": [
				"$gcc"
			],
			"group": {
				"kind": "build",
				"isDefault": true
			},
			"detail": "compiler: /usr/bin/gcc"
		}
	]
}

์—ฌ๊ธฐ์„œ "args": [ .......]   ์•ˆ์ชฝ์— ๋‘ ๊ฐ€์ง€๋ฅผ ์ถ”๊ฐ€ํ•ด์ฃผ์–ด์•ผ ํ•œ๋‹ค.

"-ansi"

"-Wall"

์ด๊ฒŒ ์ œ๋Œ€๋กœ ์ถ”๊ฐ€๊ฐ€ ๋˜์—ˆ๋‹ค๋ฉด, ๋นŒ๋“œ๋ฅผ ํ–ˆ์„ ๋•Œ ์•„๋ž˜์™€ ๊ฐ™์€ ์˜ค๋ฅ˜ ๋ฉ”์„ธ์ง€๊ฐ€ ๋œฌ๋‹ค.

 

 *  Executing task: C/C++: gcc build active file 

Starting build...
/usr/bin/gcc -ansi -Wall -fdiagnostics-color=always -g /root/prac/asd/main.c -o /root/prac/asd/main
/root/prac/asd/main.c: In function ‘main’:
/root/prac/asd/main.c:7:5: error: C++ style comments are not allowed in ISO C90
     // ์ฃผ์„
     ^
/root/prac/asd/main.c:7:5: error: (this will be reported only once per input file)

Build finished with error(s).

 *  The terminal process failed to launch (exit code: -1). 
 *  Terminal will be reused by tasks, press any key to close it.

 

 

๊ถ๊ธˆํ•œ ๊ฒƒ

1. ์šฐ๋ถ„ํˆฌ ํ„ฐ๋ฏธ๋„์—์„œ ์ตœ์ƒ์œ„ ํด๋”๋กœ ์ด๋™์„ ํ•œ ํ›„ pwd๋ฅผ ํ•ด๋ณด๋ฉด, ๋‚ด ๋…ธํŠธ๋ถ๋งŒ ์ตœ์ƒ์œ„ ํด๋”๊ฐ€ /root/... ์ด๋‹ค. ๋‹ค๋ฅธ ์‚ฌ๋žŒ๋“ค์€ ๋ชจ๋‘  /home/ubuntu/... ์˜€๋‹ค.  ์™œ ๋‹ค๋ฅธ๊ฑฐ๊ณ  ์–ด๋–ค ๋ฌธ์ œ๊ฐ€ ์žˆ๋Š”๊ฑธ๊นŒ?

 - ๊ต์ˆ˜๋‹˜๊ป˜ ์—ฌ์ญค๋ณด๋‹ˆ ์ƒ๊ด€์—†๋‹ค๊ณ  ํ•˜์‹ฌ.

 

2. tasks.josnํŒŒ์ผ์€ ๋ฌด์—‡์ด๋ฉฐ, ์ด ํŒŒ์ผ์„ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด์„œ ๋ˆ„๋ฅด๋Š” Terminal - Configure Default Build Task... ๋Š” ๋ฌด์—‡์ธ๊ฐ€?

 

LIST