linasm-1.13 library을 사용하는 Octave C++ .oct 함수를 작성하려고하지만,/usr/share/zoneinfo /에서 tzdata를 기본로드하는 것조차도 작동하지 않습니다. 내 간단한 테스트 기능은 지금까지 mkoctfile로 컴파일에,이 오류를 제공,C++ 시간 라이브러리 및 옥타브 .oct 파일
#include <octave/oct.h>
#include <Time.h> // the linasm-1.13 library
DEFUN_DLD (tz, args, nargout,
"-*- texinfo -*-\n\
@deftypefn {Function File} {} tz (@var{YYYYMMDDHHMMSS})\n\
\n\
@end deftypefn")
{
octave_value_list retval_list ;
unsigned int tz ;
const char *ny_time = "/usr/share/zoneinfo/America/New_York" ;
tz = Time::LoadTimeZone(ny_time) ;
return retval_list ;
입니다
>> mkoctfile tz.cc
tz.cc: In function ‘octave_value_list Ftz(const octave_value_list&, int)’:
tz.cc:24:34: error: cannot call member function ‘unsigned int Time::LoadTimeZone(const char*)’ without object
tz = Time::LoadTimeZone(ny_time) ;
^
warning: mkoctfile: building exited with failure status
이의 나의 이해는 그 ny_time가 인식 객체가 아닌,하지만 난 노력했다 this accepted SO answer에 설명 된대로 문자열 리터럴로 ny_time을 캐스팅합니다.
linasm page에 따른 LoadTimeZone의 입력이 "필요한 표준 시간대를 설명하는 tzfile의 경로"여야하므로이 방법을 사용하고 있습니다. 내가 어디로 잘못 가고 있니?
오류 메시지에서 'Time' 개체를 먼저 생성 한 다음 해당 개체에서'LoadTimeZone '을 호출해야합니다. 따라서,'Time' 클래스 주위에 Octave 래퍼를 제공하고, Octave 코드를 제공해야합니다. –
덧붙여 말하자면, 대부분의 경우 Swig은 수동으로 바인딩을 작성하는 것보다는 Swig를 사용하는 것이 더 좋습니다. Swig은 지루한 세부 사항을 처리하기 때문에 (그리고 Octave 바인딩 생성을 지원합니다). –
C++ 11 이상을 사용하는 경우 고려할 수있는 다른 표준 시간대 라이브러리는 다음과 같습니다. https://howardhinnant.github.io/date/tz.html 우수한 설명서와 지원을 제공합니다. –