我正在编译 Blender 的一个分支3D建模程序from source (使用 SCONS ),在 Fedora 8 机器上,我遇到了一个错误,我没有遇到在 CentOS 5 机器上编译相同的源代码,我认为它与变量定义有关。错误是:
source/blender/blenkernel/intern/implicit.c: In function ‘mul_bfmatrix_lfvector’:
source/blender/blenkernel/intern/implicit.c:592: error: ‘CLOTH_OPENMP_LIMIT’ undeclared (first use in this function)
source/blender/blenkernel/intern/implicit.c:592: error: (Each undeclared identifier is reported only once
source/blender/blenkernel/intern/implicit.c:592: error: for each function it appears in.)
source/blender/blenkernel/intern/implicit.c: In function ‘cloth_calc_force’:
source/blender/blenkernel/intern/implicit.c:1700: error: ‘CLOTH_OPENMP_LIMIT’ undeclared (first use in this function)
implicit.c
文件确实定义了该变量;这是文件的前几行:
#include "MEM_guardedalloc.h"
#include "BKE_cloth.h"
#include "DNA_object_force.h"
#include "BKE_effect.h"
#include "BKE_global.h"
#include "BKE_utildefines.h"
#include "BLI_threads.h"
#define CLOTH_OPENMP_LIMIT 25
#ifdef _WIN32
#include <windows.h>
static LARGE_INTEGER _itstart, _itend;
static LARGE_INTEGER ifreq;
抛出错误的两行是:
#pragma omp parallel sections private(i) if(vcount > CLOTH_OPENMP_LIMIT)
和
#pragma omp parallel for private(i) if(numverts > CLOTH_OPENMP_LIMIT)
我猜这个错误是由于编译器以及它在编译中定义变量时如何处理的,而且由于 Fedora 8 有点过时,它可能有一些旧版本的编译器把它搞砸了。任何人都知道如何绕过这个显示为“未声明”的变量?
最佳答案
该编译器不支持 OpenMP。这是第一次提到OpenMP和GCC
2006 年 3 月 9 日
...因此从 GCC 4.2 开始,编译器支持 OpenMP v2.5 规范。
这里的提示是,根据预处理器错误,很明显该值已定义,但 #pragma ... 行找不到该定义。一旦您意识到代码使用了非标准的#pragma 编译器指令,编译器就会成为主要嫌疑人。
关于c - "undeclared"命令中的变量 "#pragma"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3293610/