Reputation: 751
I know that inlcude_next happens to be GNU extension of the C preprocessor.
I am facing an issue compiling Gnu library code using MSVC. For instance, there is an stdio.h header file or rather GNU-like <stdio.h>
. When compiled using MS compiler, I get invalid preprocessor command 'include_next'
which is fine because there is nothing like a #include_next
directive for windows. The main aim of doing #include_next being you would like to create a file called stdio.h in your project, and that would be included instead of the default header.
So, I tried 2 options:
1) Comment out this line // #include_next <stdio.h>
in all the files.
2) Or replace #include_next by #include <stdio.h>
.
I don't know if opting for 1) will cause any problems(linker errors at the end).
Regarding 2), I got fatal error C1014: too many include files : depth = 1024
which is also fine. For this, I would use wrapper #ifndef
for the include guards or # pragma once
directive.
Following are my concerns:
Do I need to write a statement like #include <stdio>
or #include "stdio.h"
inside the header file stdio.h? Will it make any sense when compiling for Windows. Won't I suffice with just doing #include "stdio.h"
directly in all the source files where it needs, so that it would bypass the Visual C standard header and rather use mine?
And, what might/might not happen if I omit the statement include_next in entirety?
My main aim being to successfully compile gnu libraries using MSVC. Please correct me if I am missing something or perhaps throw more light on this topic.
Upvotes: 7
Views: 6299
Reputation: 76236
Neither option 1 nor 2 are going to work. It is a header that wraps the system one. So if you comment it out, the system header won't get included and it's definitions will be missing. And if you change it to plain #include
, it will include the same header again, causing infinite loop.
Boost uses
#include <../include/stdio.h>
this works on WinNT, because all the standard headers happen to be in directories called include
. It also works on standard WinCE SDKs, but unfortunately does not work on all of them.
Upvotes: 7