简体   繁体   中英

GMOCK Clang pesky error "/usr/include/limits.h:123:16: fatal error: 'limits.h' file not found"

Using Linux OS for C++ development with GMOCK framework. I have the following code.

#include <stdint.h>
#include <string>
#include "gmock/gmock.h"
#include "dispat_tasks.hh"

namespace testing {

namespace internal {
    GTEST_API_ string JoinAsTuple(const Strings& fields);
}

namespace DispatTasksTestNS {
using ::testing::Invoke;

// Fixture
class DispatTasksTest : public ::testing::Test {
 public:
    DispatTasksTest() {}
    ~DispatTasksTest() {}
    dispat_tasks SMD;
};
}  // testing NS
}

When I execute the clang syntax checking, I get the flowing error.

/usr/include/limits.h:123:16: fatal error: 'limits.h' file not found

The content of the line 123 is:

# include_next <limits.h>

Any way to resolve the error above?

sudo apt-get install libc++1

and

sudo apt-get install libc++-dev

fixed my issue

when used clang

I try -I/usr/lib64/clang/9.0.1/include/ solved my problem. The /usr/include/limits.h will start to find an alternated limits.h , which should fit the compiler's environment.

Try to find out some folder like /xxx/xxx/compiler_you_used/xxx/include

Here is what I did, in Ubuntu Linux.

In terminal:

sudo find -name "limits.h"

From the list I chose the usr/include folder and added the following compiler option:

isystem /usr/include

this solved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM