Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7931 Discussions

identifier "__builtin_expect" is undefined

DLake1
New Contributor I
2,045 Views

identifier "__builtin_expect" is undefined

please explain.

0 Kudos
1 Solution
Judith_W_Intel
Employee
2,045 Views

 

This is a GNU builtin (an extension to the GNU compiler) described here:

http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

I believe we make this available in our Windows compiler (icl) as well, although Microsoft does not.

Judy

View solution in original post

0 Kudos
6 Replies
TimP
Black Belt
2,045 Views

To begin with, the answers for Windows (in short, define it away) are different from those for linux or Mac.   Did any of the web search results (too many to discuss here) relate to your question?

The feature may have been added to icc to support linux kernel builds.  That doesn't mean it's a good idea to use it in your own code.

 

0 Kudos
DLake1
New Contributor I
2,045 Views

I'm using Windows 7 x64 and Intel compiler v14 the code is from quicklz.c here: www.quicklz.com/download.html

0 Kudos
Judith_W_Intel
Employee
2,046 Views

 

This is a GNU builtin (an extension to the GNU compiler) described here:

http://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html

I believe we make this available in our Windows compiler (icl) as well, although Microsoft does not.

Judy

0 Kudos
SergeyKostrov
Valued Contributor II
2,045 Views
>>...I believe we make this available in our Windows compiler (icl) as well... It looks very interesting and could you specify from what ICC version is it supported?
0 Kudos
SergeyKostrov
Valued Contributor II
2,045 Views
The builtin_expect is used for limit checks. Also, If interested look at GCC headers since there are lots of examples of how builtin_expect is used.
0 Kudos
emmanuel_attia
Beginner
2,045 Views

This directive is perfectly usable across Linux or Windows with that kind of macro

#if defined(__GNUC__) || defined(__ICL) || defined(__clang__)
#define EXPECT(x, y) (__builtin_expect((x),(y)))
#else
#define EXPECT(x, y) (x)
#endif


Right now only Microsoft C++ does'nt support it and with ICL (Windows Intel Compiler), it is very effective (it does what it's expected to).

0 Kudos
Reply