C
-
error: expected initializer before ‘namespace’ 해결일기개발/C, C++ 2022. 8. 12. 13:45
꽤 작성하던 코드가 갑자기 빌드가 안된다. In file included from include/log.h:3:0, from src/main.cpp:13: /usr/include/c++/4.8.2/sstream:41:1: error: expected initializer before ‘namespace’ namespace std _GLIBCXX_VISIBILITY(default) 대체 무슨 문제인가 하고 찾다가 함수나 구조체 등 무언가 선언이 완료되지 않으면 주로 발생하다는 글을 보고 찾아보았다. 내 코드의 경우 main.cpp의 13번째 줄까지는 전부 include 선언이다. 13번 째 줄도 log.h를 include하는 내용이다. 그렇다는 것은, 13번째 이전 줄의 헤더 파일 어딘가에 선언이 완료되지..
-
google test 로 C++ 단위 테스트 진행기개발/C, C++ 2022. 5. 8. 15:26
테스트 코드를 도입해야겠다고 생각하고, 순전히 하루정도 정말 테스트 코드에 대한 고민을 할 기회가 생겼다. 리눅스 환경에서 C++ 의 테스트 코드를 작성할 때, 어떤 개념으로 이 테스트 코드가 동작하는지 내가 이해한 바를 적어두려고 한다. 환경은 CentOS 7에 c++ 11 테스트는 google test 를 사용하기로 했다. 테스트 프로젝트로 단위 테스트가 없는 프로젝트에 단위 테스트를 넣는 과정은 이 글을 참고하면 된다. 예제 프로젝트에 테스트 코드를 추가하는 과정과 동작을 직접 확인할 수 있다. https://bearnet.tistory.com/22 myclass.o dbconn.cpp -(컴파일)--> dbconn.o main.cpp -(컴파일)--> main.o myclass.o dbconn.o..