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

Feature Request for a new directive <strong>#if exists - #endif</strong>

SergeyKostrov
Valued Contributor II
312 Views

I'd like to make a Feature Request for a new directive #if exists ( #include "filename.h" ) #endif. Here is example: #if exists ( "immintrin.h" ) #include "immintrin.h" #endif The directive should verify that some file exists in a folder and if Yes should set a "condition-variable" to true. Isn't that a good thing? Please consider and thank you in advance. Best regards, Sergey

0 Kudos
6 Replies
Judith_W_Intel
Employee
312 Views

 

Sergey,

If you really think this is a useful new C/C++ language/preprocessor feature I would suggest you propose this to the C and/or C++ standard committees.

Although Intel has implemented some of its own language extensions, these are generally performance extensions to take advantage of Intel chips (like parallel features). And even then we try to get them standardized so users will be able to use them and still have portable code.

Judy

0 Kudos
SergeyKostrov
Valued Contributor II
312 Views
>>...Although Intel has implemented some of its own language extensions... This is exactly what I was thinking about. However, your advise about a proposal to the C/C++ Standards Committee is very good one and I will try to do it. Thanks.
0 Kudos
jimdempseyatthecove
Honored Contributor III
312 Views

Sergey,

Consider writing a Batch or Shell script that runs prior to compilation that creats a header file (header_exists.h) and which you include into your program.

echo // header_exists.h > header_exists.h
if exist immintrin.h echo _immintrin_exist_  > header_exists.h
...

Set your VS build properties to run the script before compilation.

In you application

#include "header_exists.h"
#if defined( _immintrin_exist_)
...

Jim Dempsey

0 Kudos
SergeyKostrov
Valued Contributor II
312 Views
>>...Consider writing a Batch or Shell script that runs prior to compilation that creats a header file (header_exists.h) and >>which you include into your program... It is actually a good idea. Thank you, Jim.
0 Kudos
jimdempseyatthecove
Honored Contributor III
312 Views

oops

>>if exist immintrin.h echo _immintrin_exist_  > header_exists.h
if exist immintrin.h echo #define _immintrin_exist_  > header_exists.h

Jim Dempsey

0 Kudos
SergeyKostrov
Valued Contributor II
312 Views
Thanks to everybody. I decided to use "dummy" header files ( see note section ) for all cases when legacy C/C++ compilers don't support Intel SIMD technology or if a C/C++ compiler not fully supports the technology and some header(s) missing. Note: Fo example, immintrin.h /////////////////////////////////////////////////////////////////////////////// // immintrin.h #ifndef _DUMMY_IMMINTRIN_H_ #define _DUMMY_IMMINTRIN_H_ /////////////////////////////////////////////////////////////////////////////// //... /////////////////////////////////////////////////////////////////////////////// #endif
0 Kudos
Reply