How to properly include Armadillo in CLion (without having false errors)?

无人久伴 提交于 2020-01-03 09:30:00

问题


When I use the header-only Armadillo C++ library in CLion, the IDE indicates (highlights) multiple (false) errors in the code, however the usage of Armadillo is valid and the code builds and runs without any errors.

For example, in a very simple Armadillo test project, the IDE indicates 3 errors, as written in the comments:

#include <iostream>
#include "armadillo"

using namespace std;
using namespace arma;

int main() {
    cout << "Armadillo version: " << arma_version::as_string() << endl;
    // Returns 5.0.1 (Ankle Biter)

    mat A(2,3);  // Error: Too many arguments, expected 0
    A.fill(99);
    A(1,2) += 101.0;  // Error: Called object is not a function
    A.print("A = ");
    A.set_size(4,5); // Error: Too many arguments, expected 1
    A.fill(77);
    A.print("A = ");

    return 0;
}

Since Armadillo is header-only, I did not modify the default CMakeLists.txt file, only included the main header in main.cpp and copied armadillo_bits to the project directory.

I've tried to configure Armadillo with CMake, but on Windows it seems Armadillo's bundled CMakeLists.txt just copies the includes and creates a config.hpp in my working dir.

Is there a way to index symbols in header-only libraries?

CLion version is 1.0 (141.353), Armadillo version is 5.0.1. My platform is Windows 8.1 x64, and I'm using MinGW v64 4.9.2 (x86_64-4.9.2-win32-seh-rt_v4-rev2)

The CLion project is available in this repository.

Thanks to anyone trying to investigate this issue.

来源:https://stackoverflow.com/questions/29899738/how-to-properly-include-armadillo-in-clion-without-having-false-errors

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!