[해결]초보적인 c++질문 <string>와 <cstring>의 차이점에 대해서
geant4이라는 시뮬레이션 프로그램을 설치할려고 합니다. 정확히는 geant4.9.0.p02 입니다.
사용하고 있는 리눅스는 페도라 10 이고 g++의 버젼은 4.3.2입니다.
geant4이라는 프로그램의 설치방법은 ./Configure -build -> 잡다한 설정 -> ./Configure 로, 다른 버젼으로 install은 성공했습니다. 그런데 이버젼이 필요하게 되어서 설치를 시도해 보았습니다만 아무래도 compiler가 string 나 limits 등을 인식을 못하는것 같습니다. (그런데 error: string:No such file or directory 등의 에러메시지가 보이지 않는게 좀 꺼름직하긴 합니다. 그리고 Mac OSX Leopard에서 설치 되었음...) string->cstring, limits->climits로 바꾸면 에러 메시지가 없어지긴 합니다... 근데 프로그램 전체를 고치기에는 손이 너무 많이 들어서 힘들것 같습니다. 음.... 쓸데 없는 말이 길어졌습니다. 줄이면..
string limits 등의 include 가 정상적으로 이루어지지 않을 경우 어떻게 해야 하는가요?
이하 에러 메시지의 일부
/home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4NormalNavigation.hh: At global scope:
/home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4NormalNavigation.hh:89: error: ‘numeric_limits’ is not a member of ‘std’
/home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4NormalNavigation.hh:89: error: expected primary-expression before ‘double’
/home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4NormalNavigation.hh:89: error: expected ‘,’ before ‘double’
In file included from /home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4Navigator.hh:66,
from /home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4TransportationManager.hh:49,
from src/G4RayTrajectory.cc:45:
/home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4VoxelNavigation.hh:97: error: ‘numeric_limits’ is not a member of ‘std’
/home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4VoxelNavigation.hh:97: error: expected primary-expression before ‘double’
/home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4VoxelNavigation.hh:97: error: expected ‘,’ before ‘double’
In file included from /home/jwlee/local/geant/geant4.9.0.p02/source/geometry/navigation/include/G4Navigator.hh:67,
.....
자문자답
아무래도 fedora와 scientific linux, osx간에 include해석이 틀린거같습니다. sl와 osx는 을 string.h로 인식하는거같습니다만, fedora는 그렇지 않은것 같습니다. abs(int)함수가 cmath 가 아닌 cstdlib더군요... 일단 googleing 으로 전부 해결되었습니다.
string과 cstring은 전혀
string과 cstring은 전혀 관계없는 해더파일입니다.
string은 std::string 관련 클래스들이 선언되어있는 해더이고, cstring은 C의 string.h 내용을 std 네임스페이스에 들어가도록 재선언한 해더파일입니다.
댓글 달기