Tag Archives: TSRMLS_C

[NoSQL/Thrift] Cassandra ‘tsrm_ls’ was not declared in this scope 오류 해결하기

사용자 삽입 이미지
32비트 머신에서 Thrift의 PHP Native 컴파일을 하다보면 오류가 발생하는 경우가 있습니다.

/usr/local/src/thrift-0.6.0/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp:418: error: expected primary-expression before ‘,’ token
/usr/local/src/thrift-0.6.0/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp:418: error: ‘tsrm_ls’ was not declared in this scope
/usr/local/src/thrift-0.6.0/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp: In function ‘void protocol_writeMessageBegin(zval*, const char*, int32_t, int32_t)’:

/usr/local/src/thrift-0.5.0/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp: In function ‘void throw_zend_exception_from_std_exception(const std::exception&)’:
/usr/local/src/thrift-0.5.0/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp:416: error: expected primary-expression before ‘,’ token
/usr/local/src/thrift-0.5.0/lib/php/src/ext/thrift_protocol/php_thrift_protocol.cpp:416: error: ‘tsrm_ls’ was not declared in this scope
make: *** [php_thrift_protocol.lo] 오류 1

이경우 소스를 약간 수정해야 합니다. 저기에 보이는 php_thrift_protocol.cpp 파일의 오류가 발생한 416번째 줄로 이동을 합니다. 다음과 같은 부분의 소스입니다.
[code]// Sets EG(exception), call this and then RETURN_NULL();
void throw_zend_exception_from_std_exception(const std::exception& ex) {
  zend_throw_exception(zend_exception_get_default(TSRMLS_CC), const_cast<char*>(ex.what()), 0 TSRMLS_CC);
}[/code]
위의 소스를 다음과 같이 수정을 하시면 문제없이 컴파일이 이루어집니다.
[code]// Sets EG(exception), call this and then RETURN_NULL();
void throw_zend_exception_from_std_exception(const std::exception& ex) {
  TSRMLS_FETCH();
  zend_throw_exception(zend_exception_get_default(TSRMLS_C), const_cast<char*>(ex.what()), 0 TSRMLS_CC);
}[/code]