Skip to Content
우아한 C언어 코딩 패턴
book

우아한 C언어 코딩 패턴

by Christoper Preschem, 정기훈(Jung Ki Hun)
April 2024
Beginner to intermediate
364 pages
7h 2m
Korean
Insight
Content preview from 우아한 C언어 코딩 패턴
C
307
󼟷󼘃󽴔󻝳󼙯󺹻
{
fd
=
open("log.txt", O
_
RDWR
|
O
_
CREAT, 0666);
}
write(fd, buffer, strlen(buffer));
}
 󻱃󺲻󼨫󽴔󻳤󻳐󽴔󻆏󻛧󺝣󽴔󼨫󽴔󻅗󺺛󽴔󼇗󺋿󼬣󺣧󺼿󽴔󼨷󻛧󺃏󽴔󼬇󼉫󺣯󽴔󺨛󺺗󺞳󽴔󼇗󺋿󼬣󺣧󻺏󽴔󻨙󺝣󺞳
코드 예제를 단순하게 유지하기 위해 스레드 안전(thread safety)은 고려하지
않았다. 스레드 안전을 위해서는 뮤텍스로 지연 획득을 보호하여 코드에서 획
득이 한 번만 이루어지도록 해야 한다.
파일을 닫는 것은 어떤가? 이번 장에서 본 것과 같은 일부 애플리케이션의
경우, 파일을 닫지 않는 것도 가능한 선택이다. 애플리케이션이 실행하는 동안
로그를 남기고 애플리케이션을 종료할 때 운영 체제에 열려 있는 파일 클린업
을 맡긴다고 상상해 보자. 시스템 충돌 시 정보가 저장되지 않을까봐 걱정스럽
다면 때때로 파일 내용을 플러시(flush)할 수도 있다.
󼔻󺴫󻝳󽴔󼧛󺱺󼣋󽴔󼟛󻱋
지금까지는 리눅스 시스템의 파일에 대한 로깅 코드를 구현하였지만, 이제 윈
도우 플랫폼으로 코드를 확장하고자 한다. 지금의 코드는 윈도우에서 동작하
지 않는다.
여러 플랫폼을 지원하려면 먼저 변형 회피를 통해 모든 플랫폼에 대한 공통
코드만 갖도록 하는 것을 고려해야 한다. 이는 리눅스와 윈도우 시스템 양쪽에
서 사용할 수 있는
fopen ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

AI를 위한 필수 수학

AI를 위한 필수 수학

할라 넬슨
파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리
개발 7년차, 매니저 1일차

개발 7년차, 매니저 1일차

권원상, 한민주, 카미유 푸르니에
클라우드 네이티브 애플리케이션 디자인 패턴

클라우드 네이티브 애플리케이션 디자인 패턴

카순 인드라시리, 스리스칸다라자 수호티얀

Publisher Resources

ISBN: 9788966264742