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

Feature Request for a new directive #if exists - #endif

Sergey Kostrov's picture

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

7 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.
Judith Ward (Intel)'s picture

 

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

Sergey Kostrov's picture

>>...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's picture

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

www.quickthreadprogramming.com
Sergey Kostrov's picture

>>...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's picture

oops

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

Jim Dempsey

www.quickthreadprogramming.com
Sergey Kostrov's picture

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

Login to leave a comment.