0

I have a C++ project in Netbeans on my Linux Mint 17.2 machine. I'm using the GCC 5 toolchain (e.g. g++ 5.3.0), Netbeans 8.1, and Boost 1.61.0.

I'm encountering a weird warning in my project that shows up all over the place. For instance, in my main.cpp, I #include <iostream> at the very top, and that line gets a warning. (I see this warning happen for the first file I include in every file, so it is not an issue with iostream etc.).

The warning is that there is a recursive #include in boost. Specifically, Netbeans complains that <boost/predef/os/bsd/free.h> includes <boost/predef/os/bsd.h> and that <boost/predef/os/bsd.h> includes <boost/predef/os/bsd/free.h>. For the record, this appears to be true - does anyone know why there is this recursive include in boost, and if it is really supposed to be there?

The bigger issue is that my system is not BSD, so I don't know why I'm getting these warnings from the BSD headers, which shouldn't be included or active/defined. I tried printing BOOST_PLATFORM_CONFIG from my main.cpp, and it prints out the path to boost's Linux config header, as expected - not the BSD config header. And, my program compiles and runs fine, so I'm assuming it's never actually using the BSD headers. Which means that the fact that these BSD headers are giving me warnings might be a Netbeans problem, not a boost problem.

Does anyone have any ideas on how to narrow down and fix this issue with these strange recursive include warnings?

davewy
  • 1,781
  • 1
  • 16
  • 27
  • Releated: I'm getting the same warning as http://stackoverflow.com/questions/37236721/unable-to-resolve-template-based-identifier-get-netbeans-8-1 , though there's no answer there – davewy Aug 17 '16 at 21:59
  • Explaining the downvote would be appreciated -- seems like this problem affected multiple other people as well, so the q&a were at least a bit useful! – davewy Feb 02 '18 at 19:16

2 Answers2

3

I was having the same problem. The issue is with the boost predef/os/bsd.h header. It #includes 5 files in the #else block for the #ifndef BOOST_PREDEF_OS_BSD_H guard. This means that this header file is not guarded against recursion if any of those 5 files also includes bsd.h (which they do).

My solution was to edit the predef/os/bsd.h file and add a recursion guard in the #else block - so, starting at around line 94 my predef/os/bsd.h file now looks like:

#ifndef BOOST_PREDEF_OS_BSD_H_PREVENT_RECURSION      <-- ADD THIS
#define BOOST_PREDEF_OS_BSD_H_PREVENT_RECURSION      <-- ADD THIS

#include <boost/predef/os/bsd/bsdi.h>
#include <boost/predef/os/bsd/dragonfly.h>
#include <boost/predef/os/bsd/free.h>
#include <boost/predef/os/bsd/open.h>
#include <boost/predef/os/bsd/net.h>

#endif                                               <-- ADD THIS

And now netbeans code assistance is happy and my code still links and compiles without error.

Marvin Herbold
  • 761
  • 5
  • 4
0

The rough way: comment

#include <boost/predef/os/bsd.h>

Everywhere (should be inside the following headers)

  1. predef/os.h
  2. predef/other/endian.h
Patrizio Bertoni
  • 2,582
  • 31
  • 43
  • Ideally one wouldn't have to edit boost to get this to work. However, my question is all with out-of-date tools now, so I can't comment whether there's a similar issue with the latest gcc/boost/netbeans. – davewy Feb 02 '18 at 19:10