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.
7683 Discussions

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

SergeyKostrov
Valued Contributor II
96 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
96 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

SergeyKostrov
Valued Contributor II
96 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.
jimdempseyatthecove
Black Belt
96 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

SergeyKostrov
Valued Contributor II
96 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.
jimdempseyatthecove
Black Belt
96 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

SergeyKostrov
Valued Contributor II
96 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
Reply