본문 바로가기

Programming/C & C++43

C & C++ 에서 현재 파일 이름과 줄번호를 얻어오는 방법 #include int main() { printf("Filename : %s\n" , __FILE__); printf("Line no : %d\n" , __LINE__); printf("Function : %s\n" , __func__); printf("Function : %s\n" , __FUNCTION__); return 0; } Information C 에서 사용하는 매크로를 이용하면 된다. 1. 파일 : __FILE__ 2. 줄번호 : __LINE__ 3. 함수명 : __FUNCTION__ , __func__ (__func__ 는 C99 에서 새로 추가된 녀석. 가능하면 _func__를 사용하자) Example Result FileName : main.cpp Line no : 5 Function.. 2023. 5. 12.
자주 접하는 오류문들 error: ISO C++ forbids declaration of ‘자료형’ with no type-------------------------------------------------------------------------------------------원인 : 자료형이 제대로 선언되지 않은채 사용되었다.해결 : 1. 이 자료형이 선언된 헤더파일의 경로 및 파일이름이 올바른지 확인한다. 2. namespace안에 구현된 경우일 수도 있으니 namespace를 사용했는지 확인한다.error: 'NullLock' was not declared in this scope---------------------------------------------------------------------------.. 2023. 5. 9.
C++ Errors error LNK2019: __imp_WSAStartup12345678910111213LINK : xxxxxxxxxxxxxxxxxxxxx(를) 찾을 수 없거나 마지막 증분 링크에 의해 빌드되지 않았습니다. 전체 링크를 수행하고 있습니다.xxxxxx : error LNK2019: __imp_htons 외부 기호(참조 위치: "public: static int __cdecl ifs::core::wpl::Marshal::encode(void *,unsigned short)" (?encode@Marshal@wpl@core@ifs@@SAHPEAXG@Z) 함수)에서 확인하지 못했습니다.) : error LNK2001: __imp_htons 외부 기호를 확인할 수 없습니다.1>ifs100_test.lib(Marsha.. 2014. 11. 5.
C++ Multi Platform Issues Little Endian & Big Endianstruct 의 경우 variable의 bit order 변경 뿐 아니라 variable의 순서도 바뀌게 된다. 따라서 아래와 같이 little endian에서 작성된 struct는 big endian machine 에서 역순으로 기술되어야 한다. 1234567891011121314struct _MULTI_PLATFORM_STRUCT { #ifdef _IS_LITTLE_ENDIAN_ // _IS_LITTLE_ENDIAN_ is a custom definition to explain the variable order unsigned int pos : 20; unsigned int weight : 5; unsigned int field : 2; unsigned .. 2014. 7. 1.