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

__INCLUDE_LEVEL__

imakris
Beginner
630 Views
Hello,

I tried to use the __INCLUDE_LEVEL__ preprocessor macro with the 9.1 c++ compiler for windows but it seems it's not supported, not in msvc either. Is there any way to get it to work?

Thanks


#include

using namespace std;

int main()
{
cout << __INCLUDE_LEVEL__ << endl;
}


error: identifier "__INCLUDE_LEVEL__" is undefined

0 Kudos
3 Replies
Dale_S_Intel
Employee
630 Views

As far as I can tell, __INCLUDE_LEVEL__ is a gcc extension(http://www.mhatt.aps.anl.gov/dohn/programming/gcc/cpp_3.htmlsection 3.7.2) and thus it's not likely that you'd find support for it on Windows, except with gcc.

That being said, it appears that icc doesn't have support for it even on Linux. I can file an issue on that, but I'm not sure that will help your case on Windows.

Just out of curiosity, how crucial is this to your code? And how are you using it?

Thanks!

Dale

0 Kudos
imakris
Beginner
630 Views
Well, I am writing something with very repetitive code, so I thought of the following trick:


//-------file main.c----------

#include

int main()
{
#define REP_LIMIT 10
#define REP(BLAH)
printf("%d ", BLAH);
#include "rep.h"
return 0;
}


//--------file rep.h----------

#if __INCLUDE_LEVEL__ < REP_LIMIT
REP(__INCLUDE_LEVEL__)
#include "rep.h"
#endif


It's not very useful here, but together whth the ## preprocessor operator it could be used when dealing with multiple numbered variables (e.g. foo1, foo2, foo3 etc)
0 Kudos
jimdempseyatthecove
Honored Contributor III
630 Views

Roll your own. Suggestion:

-------file main.c----------

#include

int main()
{
#define REP_LEVEL 0
#define REP_LIMIT 10
#define REP(BLAH)
printf("%d ", BLAH);
#include "rep.h"
return 0;
}


//--------file rep.h----------
#define NEXT_REP_LEVEL (REP_LEVEL+1)
#define REP_LEVEL NEXT_REP_LEVEL
#if REP_LEVEL < REP_LIMIT
REP(REP_LEVEL)
#include "rep.h"
#endif

0 Kudos
Reply