代码之家  ›  专栏  ›  技术社区  ›  MidnightLightning

“#pragma”命令中的变量“undeclared”?

  •  1
  • MidnightLightning  · 技术社区  · 14 年前

    我正在编译 Blender 三维建模程序 from source (使用 SCONS ),我遇到了一个在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)
    

    我猜这个错误是由于编译器以及它在编译中定义变量时的处理方式造成的,而且由于Fedora8有点过时,它可能有一个旧版本的编译器把它搞乱了。有人知道我如何绕过这个显示为“undeclared”的变量吗?

    4 回复  |  直到 9 年前
        1
  •  1
  •   jdu.sg    14 年前

    那个编译器不支持OpenMP。这是第一次提到OpenMP和GCC

    2006年3月9日

    这里的提示是,非常清楚地定义了值,但是#pragma。。。根据预处理器错误,行找不到定义。一旦意识到代码使用的是非标准的#pragma编译器指令,编译器就成了主要的嫌疑犯。

        2
  •  0
  •   Mark B    14 年前

    好像是出于某种原因 CLOTH_OPENMP_LIMIT

    #ifndef CLOTH_OPENMP_LIMIT
    #error "Ooops, CLOTH_OPENMP_LIMIT not defined!"
    #endif
    

    常见的原因是,它依赖于其他预处理器定义的定义,或者在预期的情况下没有包含头。

        3
  •  0
  •   user195488 user195488    14 年前

    1. 将define CLOTH\u OPENMP\u LIMIT更改为其数值并重新编译

    如果这仍然不起作用,那么 OpenMP API 您的编译器上的文件已过期、未安装或无法工作。

        4
  •  0
  •   Jens Gustedt    14 年前