분류 전체보기 99

[Virtualbox & MacOS] Failed to query SMC value from the host (VERR_INVALID_HANDLE).

에러Failed to query SMC value from the host (VERR_INVALID_HANDLE).상황macOS catalina를 VirtualBox에 설치하고, 실행하려고 했을 때 발생한 에러 코드가상환경 창도 열리지 않는다.해결법cd 'C:\Program Files\Oracle\VirtualBox\' 실행해서 해당위치로 이동해서 (댓글에 적어주신분 감사합니다)(윈도우기준).\VBoxManage.exe setextradata "macOS" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 0원인"Value 1 will cause the SMC error message, so change it to 0."from Phùng Duy Nghĩa ..

프로그래밍 2022.04.12

[rust] Struct & #[derive(Debug)]

Rust Language Book 에서 chapter 5.2 에서 struct을 배우는 간단한 프로그래밍인데, Debug를 위한 rust 기능들이 있어서 이를 기록하기 위해서 작성하였다. 간단하게 struct는 c/c++에서 사용하는 방법과 비슷한다. struct Rectangle { width : u32, height : u32, } fn main() { let rect1 = Rectangle { width : 30, height : 50, }; println!("rect1 is {}", rect1); // Compile error } /* 에러 내용 = help: the trait `std::fmt::Display` is not implemented for `Rectangle` = note: in f..

[rust] Ownership 3 - Reference

C++에서 reference를 알고계시면 이해하기 조금 더 수월하다. 기존의 Ownership Rule은 string을 함수의 매개변수로 넘겨주게 되면 Ownership을 넘겨주는 것이라서, 함수가 끝나고 변수가 invalid되는 것이다. 이를 해결하기 위해 나온 개념이 reference이다. Ownership을 넘겨주는 것이 아닌, pointer를 넘겨주면서 함수이후 변수가 invalid가 되는 것을 방지한다. fn main(){ let s1 = String::from("hello"); let len = calculate_length(&s1); println!("The length of '{}' is {}.",s1,len); } fn calculate_length(s : &String) -> usize..

[rust] Ownership 2

Ownship 을 리턴 값이 있는 함수에서 보자. fn main() { let s1 = gives_ownership(); let s2 = String::from("hello"); let s3 = takes_and_gives_back(s2); } fn gives_ownership() -> String { let something = String::from("yours"); something } fn takes_and_gives_back(a_string: String) -> String { a_string } 함수에서 문법은 코틀린과 비슷하다. 메인 함수에서 s1,s2,s3을 선언한다. s1 변수부터 보면 gives_ownership 함수에서 리턴 값을 받아온다. 해당 함수에서 something 변수는 함수..

[rust] Ownership 1

Stack과 heap에 대한 이해가 필요하다. 일반적으로 (스크립트언어가 아니라면) 컴파일 타임에 size를 알수없는경우 heap에 저장한다고 보면 된다. 특징 1. 모든 변수는 scope를 벗어나면 invalid 된다. Ownership Rules 1. 러스트의 모든 value는 owner를 가지고 있다. 2. 하나의 owner만 가질 수 있다. 3. scope를 벗어나면, value는 없어진다. 가비지컬렉션을 사용하지 않는 언어에서는 직접 메모리를 할당/해제해주어야 하는데, rust에서는 ownership이라는 것을 이용한다. (이를 통해 안전하고 효율적으로 코드를 짤 수 있다고 한다.) 예시 (string literal의 경우 스택에 저장된다.) {// s는 invalid한 상황. let s = "..

[rust] note: the msvc targets depend on the msvc linker but `link.exe` was not found

에러 note: the msvc targets depend on the msvc linker but `link.exe` was not found note: please ensure that VS 2013, VS 2015, VS 2017 or VS 2019 was installed with the Visual C++ option 상황 scoop을 통해 rust를 uninstall하고 rustup을 다시 설치하였다. 그 이후 cargo build를 하려고하니 해당 에러가 발생하였다. msvc 계열은 보통 visual studio 에서 많이 붙는 네이밍인데, 나는 보통 gcc/g++과 같은 gnu 계열을 사용하오 있는 상황이었다.(이전 rust도 gcc설치하고 사용했었음) 해결법 rustup show 커맨드로..

[rust] 윈도우에서 러스트 시작해보기

윈도우에서 환경변수 설정, 커맨드를 통한 패키지 설치가 어려워서, scoop을 활용을 이용하였다. (보통 개발시 wsl을 활용하여 개발한다.) 예전에 설치해서 기억이 안나서, 다른 링크로 공유하겠다. https://okky.kr/article/592228 OKKY | 개발툴 및 어플을 편하게 설치 해주는 scoop 커멘드라인 인스톨러 안녕하셔요. 팁이라고 하기에도 뭐하지만.. 윈 7시절부터 쓰다보니 워낙 편해서 한번 올려봅니다. 아래는 공홈이구요. OFFICIAL HOMEPAGE : https://scoop.sh/ 개발툴 및 어플을 커멘드라인 몇줄로 아주 편 okky.kr scoop은 리눅스에서 apt, 맥북에서의 homebrew라고 생각하면 좋다. 설치가 되었다면, 해당 명령어로 필요한 것을 설치한다...

[qwiklab] 클라우드 리소스 생성 및 관리 : 챌린지 실습

실습을 따라하면서 진행했는데도 어려워서 간단하게 적어두었다. gcloud compute instances create nucleus-jumphost-815 --machine-type f1-micro --zone us-east1-b gcloud config set compute/zone us-east1-b gcloud container clusters create nucleus-cluster gcloud container clusters get-credentials nucleus-cluster kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:2.0 kubectl expose deployment hello-serve..

[HackerRank][Python] Day 29 : Bitwise AND

어려운 문제는 아니지만 내가 보통 푸는 방법과 다르게 풀어서 정리해두려고 한다. 문제 Objective Welcome to the last day! Today, we're discussing bitwise operations. Check out the Tutorial tab for learning materials and an instructional video! Task Given set . Find two integers, and (where ), from set such that the value of is the maximum possible and also less than a given integer, . In this case, represents the bitwise AND operator..

[백준][c++] 7662 이중 우선순위큐

문제 이중 우선순위 큐(dual priority queue)는 전형적인 우선순위 큐처럼 데이터를 삽입, 삭제할 수 있는 자료 구조이다. 전형적인 큐와의 차이점은 데이터를 삭제할 때 연산(operation) 명령에 따라 우선순위가 가장 높은 데이터 또는 가장 낮은 데이터 중 하나를 삭제하는 점이다. 이중 우선순위 큐를 위해선 두 가지 연산이 사용되는데, 하나는 데이터를 삽입하는 연산이고 다른 하나는 데이터를 삭제하는 연산이다. 데이터를 삭제하는 연산은 또 두 가지로 구분되는데 하나는 우선순위가 가장 높은 것을 삭제하기 위한 것이고 다른 하나는 우선순위가 가장 낮은 것을 삭제하기 위한 것이다. 정수만 저장하는 이중 우선순위 큐 Q가 있다고 가정하자. Q에 저장된 각 정수의 값 자체를 우선순위라고 간주하자. ..

반응형