Include_next preprocessor causing problems in MSVC

I know that inlcude_next is an extension of the GNU C preprocessor. I ran into the problem of compiling Gnu library code using MSVC. For example, there is a header file stdio.h or rather GNU-like <stdio.h> . When compiled using the MS compiler, I get an invalid preprocessor command 'include_next' , which is fine because there is nothing like the #include_next directive for windows. The main purpose of creating #include_next is that you would like to create the stdio.h file in your project, and this will be included instead of the default header.

So, I tried 2 options: 1) Comment on this line // #include_next <stdio.h> in all files. 2) Or replace #include_next with #include <stdio.h> .

I don't know if the choice 1) will cause any problems (linker errors at the end). As for 2), I got fatal error C1014: too many include files : depth = 1024 , which is fine too. For this, I would use wrapper #ifndef for security guards included or the # pragma once directive.

The following are my concerns:

Do I need to write instructions like #include <stdio> or #include "stdio.h" inside the stdio.h header file? Will this make sense when compiling for Windows. Isn’t it enough for me to simply #include "stdio.h" directly in all the source files where it is needed, so that it bypasses the standard Visual C header and uses mine, rather? And what can / cannot happen if I omit the whole include_next statement?

My main goal is to successfully compile gnu libraries using MSVC. Please correct me if I missed something or perhaps shed light on this topic.

+2
source share
1 answer

None of options 1 and 2 will work. This is the title that wraps the system. Therefore, if you comment on this, the system header will not be included and definitions will be absent. And if you change it to the usual #include , it will include the same header again, causing an infinite loop.

Boost uses

 #include <../include/stdio.h> 

this works in WinNT because all the standard headers are in directories called include . It also works on the standard WinCE SDKs, but unfortunately does not work on all of them.

+3
source

All Articles