#include "tbbspin_mutex.h" breaks C++?

#include "tbbspin_mutex.h" breaks C++?

Very noob question here:

When I #include "tbb\spin_mutex.h" into my header file, i get a whole flood of unhelpful C++ related errors that make very little sense (the C++ compiler very rarely emits useful errors). Commenting it out fixes the problem. I am loading "tbb\tbb_stddef.h" right before "tbb\spin_mutex.h"

I'm using the Intel C++ Compiler 11.0.066 IA32-target on a x64 Windows Vista System.

Very odd, any thoughts before I start going through line-by-line?

9 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Quoting - Oren
When I #include "tbbspin_mutex.h" into my header file, i get a whole flood of unhelpful C++ related errors that make very little sense (the C++ compiler very rarely emits useful errors). Commenting it out fixes the problem. I am loading "tbbtbb_stddef.h" right before "tbbspin_mutex.h"

I'm using the Intel C++ Compiler 11.0.066 IA32-target on a x64 Windows Vista System.

Very odd, any thoughts before I start going through line-by-line?

Hmmmm. spin_mutex.h actually includes tbb_stddef. h on its own so that should be extraneous and innocuous (it shouldn't hurt anything to explicitly include it but it should not be necessary). Do you get the same problem if you don't cross-compile from a 64-bit machine to a 32-bit machine?

Hi, Oren,

I tried to re-create your environemnt and build TBB. I opended VS 2008 x32 (not x64_32) and set paths to point to icl 11.0.066 ia32 (...cpp/bin/ia32, ...cpp/lib/ia32). When I launched 'gmake', I was able to build TBB and compile all test programs without any trouble. Could you show us what your build environment look like? The difference between yours and mine may have played a role inyour seeing so many error messages?

-wooyoung

Quoting - Wooyoung Kim (Intel)

Hi, Oren,

I tried to re-create your environemnt and build TBB. I opended VS 2008 x32 (not x64_32) and set paths to point to icl 11.0.066 ia32 (...cpp/bin/ia32, ...cpp/lib/ia32). When I launched 'gmake', I was able to build TBB and compile all test programs without any trouble. Could you show us what your build environment look like? The difference between yours and mine may have played a role inyour seeing so many error messages?

-wooyoung

The problem was that I have the following functions defined in a header:

template
T max(const vector&)

template
T max(const T&, const T&)

Where apparently tbb_stddef.h did
#define max(a,b) ( (a) > (b) ? (a) : (b) )

which confused the hell out of my compiler (preprocessor definition tend to do that!) in a way that did not emit a useful error message. I changed my function names to Max and that fixed it.

This is clearly my fault for not have my own namespace and for using such a generic name.

Thanks for you attention, sorry to waste your time on such a triviality.

Oren

I bet neither tbb_stddef.h nor other public TBB header define such a macro as max. We use rather strict rules for macro names, and this one would never flow through code review. More likely, it was included with some standard header used in TBB.

Quoting - Alexey Kukanov (Intel)

I bet neither tbb_stddef.h nor other public TBB header define such a macro as max. We use rather strict rules for macro names, and this one would never flow through code review. More likely, it was included with some standard header used in TBB.

My sincere apologies for the unintended slur. I should have been more clear. It wasn't defined before I included tbb_stddef.h and then it was defined afterwards.

Oren

Quoting - Oren

My sincere apologies for the unintended slur. I should have been more clear. It wasn't defined before I included tbb_stddef.h and then it was defined afterwards.

Oren

Oren Ijustgrep'd the source/headers and there is a singleoccurrenceof the word max in all of tbb's headers, and it was a size_t max, everything else was along the lines of max_size or some other long-winded name. Which means tbb isn't doing #define max(). Thus the culprit has to be somewhere else in your code base, maybe one of your co-workers added it to one of their source files at the same time you included tbb, or what not.

Or as Alexey points out its probably in a standard header.
But I doubt Intel's compiler or Microsoft's standard header would have a #define max.

Quoting - robert.jay.gould

Oren Ijustgrep'd the source/headers and there is a singleoccurrenceof the word max in all of tbb's headers, and it was a size_t max, everything else was along the lines of max_size or some other long-winded name. Which means tbb isn't doing #define max(). Thus the culprit has to be somewhere else in your code base, maybe one of your co-workers added it to one of their source files at the same time you included tbb, or what not.

Or as Alexey points out its probably in a standard header.
But I doubt Intel's compiler or Microsoft's standard header would have a #define max.

Think again about Microsoft. Line 190 of windef.h (%Program Files%Microsoft SDKsWindowsv6.0AInclude):

#ifndef NOMINMAX
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif /* NOMINMAX */

The tbb headers (mutex.h, tbb_thread.h, tick_count.h and a few others) include windows.h, which includes windef.h (line 155).

Oren

PS. As an aside, I find it a bit disturbing that you blame my coworkers when my original post states that simply commenting out the tbb includes fixes the problem. is a huge pile of steaming ****** and I blame microsoft for that, but I was right in my assessment that the tbb headers were #defining a max macro in some fashion.

Quoting - Oren

Think again about Microsoft. Line 190 of windef.h (%Program Files%Microsoft SDKsWindowsv6.0AInclude):

#ifndef NOMINMAX
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#endif
#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#endif /* NOMINMAX */

So this means TBB should defineNOMINMAX when building on Windows. Anyways I'm amazed Windows.h is written like it was the early 1990's (probably was and never changed...).

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi