开发者

Variable "undeclared" in "#pragma" command?

I'm compiling a branch of the Blender 3D modeling program from source (using SCONS), on a Fedora 8 box, and am running into an error that I didn't encounter compiling the same source on a CentOS 5 box, and I'm thinking it has to do with the variable definition. The error is:

s开发者_开发问答ource/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)

The file implicit.c does define that variable; here's the first few lines of the file:

#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;

the two lines that are throwing an error are:

#pragma omp parallel sections private(i) if(vcount > CLOTH_OPENMP_LIMIT)

and

#pragma omp parallel for private(i) if(numverts > CLOTH_OPENMP_LIMIT)

I'm guessing the error is due to the compiler and how it handles when in the compilation that variable gets defined, and since Fedora 8 is a bit outdated, it might have an older version of some compiler that's messing it up. Anyone have an idea how I can get around this variable showing up as "undeclared"?


That compiler doesn't support OpenMP. This is the first mention of OpenMP and GCC

March 9, 2006

... so starting with GCC 4.2 the compiler supports the OpenMP v2.5 specification.

The tip off here is that quite clearly the value is defined, yet the #pragma ... line can't find the definition, according to the pre-processor error. Once you realize that the code is using a non-standard #pragma compiler directive, the compiler becomes the prime suspect.


It looks like for some reason CLOTH_OPENMP_LIMIT is not in fact being defined. You can test this right before the lines that generate the error:

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

Common reasons would be that it depends on OTHER preprocessor defines being defined, or a header isn't included when expected.


Hard to say, but either :

  1. Change the define CLOTH_OPENMP_LIMIT to it's numeric value and recompile
  2. Check your include statements to ensure that CLOTH_OPENMP_LIMIT is actually being defined correctly.

If that still does not work, then the OpenMP API on your compiler is out-of-date, not installed, or not working.


I guess that OpenMP in gcc was still quite experimental in the old days when 4.1 came out. What happens if you replace the macro name in the OpenMP pragma by the numerical constant? I am not quite sure what the standards say about macro replacements inside pragmas, maybe this older version of gcc has a different strategy for that than newer ones.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜