Intel® C++ Compiler
Support and discussions for creating C++ code that runs on platforms based on Intel® processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.
7680 Discussions

identifier "__builtin_expect" is undefined

DLake1
New Contributor I
847 Views

identifier "__builtin_expect" is undefined

please explain.

0 Kudos
1 Solution
Judith_W_Intel
Employee
847 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

6 Replies
TimP
Black Belt
847 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.

 

DLake1
New Contributor I
847 Views

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

Judith_W_Intel
Employee
848 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

SergeyKostrov
Valued Contributor II
847 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?
SergeyKostrov
Valued Contributor II
847 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.
emmanuel_attia
Beginner
847 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).

Reply