본문 바로가기

C.C++/코드8

asio io_service 한방이해 #include #include #include #include #include asio::io_service io_svc;int a = 0; void WorkerThread(){std::cout 2018. 4. 15.
예외처리가 안되었을 경우에 terminate 에서 abort 말고 커스텀 함수 호출하는 법 c++에서는 Exception이 throw 됐을 때 처리되지 않으면(catch 구문을 통해 맞는 catch 구문을 찾을 수 없을 경우) terminate를 호출하고, 이 terminate는 기본으로 abort를 호출한다. (terminate : http://www.cplusplus.com/reference/exception/terminate/) 보통 이런 경우는 개발자가 실수한 경우이기 때문에 이런 경우에서 조금이라도 도움을 주기 위해서 abort 외에 다른 함수를 호출하여 처리되지 않았음을 알려줄 수 있지 않을까? 해서 쓴다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 #include void plus(int * ptr) { if(!ptr) throw std::in.. 2017. 12. 10.
에러값 리턴 이런짓은 되도록 하지 말자 jwqe764241::error::ERROR__ jwqe764241::registry::openRegistry( _In_const HKEYhRoot, _In_const wchar_t * lpSubKey, _Out_HKEY&result ) { jwqe764241_ASSERT(hRoot != NULL && lpSubKey != NULL, "Arguments must not be a NULL value"); jwqe764241::error::ERROR__ returnCode = RegOpenKeyEx(hRoot, lpSubKey, NULL, KEY_ALL_ACCESS, &result); if (returnCode == ERROR_SUCCESS) { return ERROR_OK; } .. 2017. 5. 23.
assertion assertion은 간단하게 말해서 프로그램 실행시간에 조건을 강제한다고 보면 된다. 다른말로 하자면 그 조건에 무조건 만족해야만 하도록 할 때에 그 조건을 검사하기 위해 하는것이라고 보면 된다. 또 다른말로 하자면 에러검출, 데이터체킹이라고 보면 된다. cassert에 적혀있는 assert는 다음과 같다.#ifdef NDEBUG #define assert(expression) ((void)0) #else _ACRTIMP void __cdecl _wassert( _In_z_ wchar_t const* _Message, _In_z_ wchar_t const* _File, _In_ unsigned _Line ); #define assert(expression) (void)( \ (!!(expression)).. 2017. 5. 18.