【问题标题】:Templates and name lookup with `stdio.h` functions使用 `stdio.h` 函数查找模板和名称
【发布时间】:2023-03-17 08:50:01
【问题描述】:

我正在尝试使用 MinGW 在 32 位 Windows 7 中构建 PCL 库。在构建outofcore 模块时,我收到了几条关于_fseeki64 的错误消息:

error: there are no arguments to '_fseeki64' that depend on a template parameter, so a declaration of '_fseeki64' must be available

octree_disk_container.h文件中,有一个

#ifndef WIN32
#define _fseeki64 fseeko
#endif

我已经测试过(生成#error)并且WIN32 是在处理文件时定义的。 _fseeki64 似乎可用于编译器,因为这个小测试程序编译:

#include "stdio.h"
int main(int argc, char** argv) {
  FILE* f = fopen("C:/a.txt","r");
  if(!f) printf("NOPE");
  int seekret = _fseeki64(f,4,SEEK_SET);
  (void)seekret;
  return 0;
} 

如果我将_fseeki64 定义为fseeko64,则错误消失并且模块编译,但我不确定fseeko 的行为是否与fseeki 的行为相同。

那么,我该怎么做才能在这种情况下使用_fseeki64?也许声明一个新的基类,将#define 放在那里,然后像Base<T>::_fseeki64 一样调用它? (从here得到想法)

你有什么想法?

【问题讨论】:

    标签: c++ templates mingw fseek name-lookup


    【解决方案1】:

    所以问题似乎是您的 MinGW 系统执行 #define WIN32,但 _fseeki64 是 Microsoft 主义,而不是 MinGW 知道的 POSIX 事物。我认为您应该在 MinGW 上使用 POSIX 行为,这意味着使用 fseeko

    【讨论】:

    • 使用fseeko 会产生一个新错误,因为fseeko 无法识别。我浏览了MinGW 目录,结果只定义了fseeko64__mingw_fseeko64。我想fseeko64 是正确的选择,不是吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-25
    • 1970-01-01
    • 1970-01-01
    • 2013-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多