1

I am using the nlohmann json (https://github.com/nlohmann/json) library (1 single json.h file) with Qt. I realize Qt has it's own json functionality, so assume that any third party header may be used. Qt generates a whole lot of issues/warnings and I would like to try suppress issues/warnings for just the json.h file.

[EDIT] Interestingly the json third party library has been updated from v3.3.0 to v3.4.0 and all warnings gone (probably best outcome). Nonetheless, being able to suppress third party warnings would still be great.

I tried the suggestions here, by putting the .h in a sub directory as well as adding the sub directory to the INCLUDEPATH. $$PWD will apparently give the current directory of the .pro file. But there is no change after doing this.

INCLUDEPATH += $$PWD/thirdparty
QMAKE_CXXFLAGS += -isystem $$PWD/thirdparty/

The warnings are easy to reproduce by the simple hello world example below:

#include <QCoreApplication>
#include <QDebug>
#include "json.h"
using namespace nlohmann;

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);
    qDebug() << "hello world";
    return a.exec();
}

[EDIT] Still hoping for some help. From the comments I have tried wrapping the inclusion, which didn't work, with what is seen below:

#pragma warning(push, 0)
#include "json.h"
#pragma warning(pop)

I am using qmake but thought that maybe gcc solutions might apply, seems they don't.

Any help would be greatly appreciated.

Nick Law
  • 115
  • 3
  • 13
  • Did you try to suppress all warnings from that header with adding `#pragma warning(push, 0) ... #pragma warning(pop)` around inclusion in your code? – vahancho Oct 24 '18 at 12:18
  • @vahancho, I assume you mean by wrapping the #include "json.h" with that? I just tried it and got the initial warnings plus two new "warning: ignoring #pragma warning [-Wunknown-pragmas]". I also tried something like https://stackoverflow.com/questions/3378560/how-to-disable-gcc-warnings-for-a-few-lines-of-code but not sure if I did that correctly. – Nick Law Oct 24 '18 at 12:47
  • Yes, I meant wrapping "json.h" with pragma declarations. Ah, you compile with GCC? Well, you can try to wrap the same include with `#pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wall" #include "json.h" #pragma GCC diagnostic pop` – vahancho Oct 24 '18 at 12:59
  • @vahancho, tbh I'm not entirely sure how this qt compiler works. I think it's technically qmake which I thought was GCC? I just use the qt build and qt does whatever magic that it does. But yeah I did try above before with no change – Nick Law Oct 24 '18 at 13:20

0 Answers0