-
카테고리
-
세부 분야
인공지능
-
해결 여부
해결됨
컴파일 시의 <typeinfo> 관련 에러
22.10.12 08:21 작성 조회수 295
0
이 강의가 아니라, 다른 강의에서 나온 질문인데, 정보 공유 차원에서 올립니다.
실습 코드를 클라우드 환경에서 돌리고 있고, gcc version 7.5 를 쓰고 있습니다.
컴파일 시에 다음 에러가 발생합니다.
$ make
nvcc -gencode=arch=compute_37,code=\"sm_37,compute_37\" -arch=sm_37 -O2 -o 12c.exe 12c.cu
./common.cpp(115): error: <typeinfo> must be included before typeid is used
답변을 작성해보세요.
0
드립커피+한모금더
지식공유자22.10.12 08:22
이 강의가 아니라, 다른 강의에서 나온 질문인데, 정보 공유 차원에서 올립니다.
문의하신 내용은 GCC version 이 낮은 경우에 발생하는 것 같습니다.
typeid 연산자가 C++11 표준이지만, 예전 컴파일러 들은 별도 header file 을 필요로 하는 경우도 있습니다.
common.cpp 앞부분에, #include <typeinfo> 를 추가해 보시면 될 것 같습니다.
아래와 같이 하면 됩니다.
// common.cpp
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#define USEMATH_DEFINES // to use M_PI
#include <math.h>
#if defined(__CUDACC__)
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <cuda_runtime.h>
#endif
#include <typeinfo> // 추가
#include <iostream>
#include <iomanip>
#include <chrono>
using namespace std;
(이하 생략)
답변 1