I have next problem( using xcode4, language c++, compiler LLVM GCC 4.2 )
In the source code, do not highlights warnings "unused parameter". In the project settings, this warning has flag 'Yes'.
For example:
void foo( int x, int y ) // There are no highlighting of warning
{
return x*x;
}
What should I do to switch on a highlighting?
You'll find the compiler settings in the project settings under Build Settings.
http://boredzo.org/blog/archives/2009-11-07/warnings
Related
I need to switch off some warnings that the Clang static analyzer (clazy) flags in some Qt code that I work with.
Appending '// NOLINT' as a comment to code lines that get flagged by clazy does not work, apparently because Qt is transformed to C++ code before clazy gets to see it, dispensing with all comments and pragmas. Appending '// clazy:exclude...' does not work either, and likewise with
#if defined(__clang__) // if that is even the right define to look for
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-W..."
#endif
...
#if defined(__clang__)
#pragma clang diagnostic pop
#endif
Is there any elegant way of getting rid of clazy warnings in Qt code? I would prefer it to be applicable to individual lines as opposed to disabling warnings on entire files.
You should use
<your code> // clazy:exclude=<warning>,<another warning>
For example, I get clazy-strict-iterators warning in my code.
I've added // clazy:exclude=strict-iterators in the end of line, and the warning is gone.
Note that you should not add clazy- prefix to the warning name.
Source: https://blogs.kde.org/2016/04/25/clazy-suppressing-warnings
I don't know why I am getting error or these statements. The same code works fine when I compile it for x86_64 system but when I changed target to Beaglebone Black and switched to angstrom tool chain the QTcreator started giving error in these lines.
//connect(process, &QProcess::readyReadStandardError, [=]{
ui->textBrowser->append(process->readAllStandardError());
});
connect(process, &QProcess::readyReadStandardOutput, [=]{
ui->textBrowser->append(process->readAllStandardOutput());
});
Errors are for the expression "[=]". Infact I don't know why this error is coming. Could this be related to version, bcoz BBB is have qt4-embedded. Any help would be appreciated.
The syntax for connecting signal to c++11 lambda has been added to Qt 5. Since previous version (Qt4) doesn't define the right signature for connect(), you can't use it. You should transform your code to match the correct syntax:
connect(process, SIGNAL(readyReadStandardError()), receiver, SLOT(yourCustomSlot()) );
With a slot declared as follow:
class MyReceiverClass {
slots:
void yourCustomSlot() {
ui->textBrowser->append(process->readAllStandardOutput());
}
};
I am using "Qt Creator 3.3.0 (opensource)" with "Qt 5.4.0 (MSVC 2010, 32 bit)"
In my camera class I'm getting weird errors I am not able solve it..
class camera
{
public:
// for view matrix
float theta, phi;
float zoom;
// for projection matrix
float fovy;
float width, height;
float near, far;
camera();
camera(float inWidth, float inHeight );
~camera();
mat4 perspective();
mat4 view();
};
I'm getting error at line:
float near, far;
Errors are:
error: C2059: syntax error : ','
error: C2238: unexpected token(s) preceding ';'
error: C1903: unable to recover from previous error(s); stopping compilation
error: C2059: syntax error : ','
error: C2238: unexpected token(s) preceding ';'
What I'm doing wrong ?
near and far are reserved keywords for memory model in C language. They are used in pointer declaration.
You need to use another names. You may view at this question for details.
I'm struggling to get a subclass of QGLWidget compiled that uses glew. I'm running Qt 5.0.1 + MinGW 4.7 on Windows 7. Glew 1.7.0 has been compiled with said MinGW.
I have subclassed QGLWidget with UGGLWidget and included "GL/glew.h" before the QGLWidget includes. When compiling I get 200 Errors about:
'function' redeclared as different kind of symbol
conflicting declaration 'typedef'
So my Question:
How do I get a subclass of QGLWidget that uses glew compiled under Qt5?
Edit: I tried the same approach with another setup (Qt4.7 + MinGW4.4). It compiles and runs just fine. I have also tried using a more recent version of glew (Qt5.0.1 + MinGW4.7 + glew1.9.0) this doesn't compile either and gives the same compilation errors.
Here's a messy snippet of the compiler output:
> In file included from
> ..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include/QtGui/qopengl.h:55:0,
> from ..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtOpenGL/qgl.h:47,
> from ..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include\QtOpenGL/QGLWidget:1,
> from src\UGGLWidget.h:4,
> from src\UGGLWidget.cpp:2: ..\..\..\..\..\..\Qt\Qt5.0.1\5.0.1\mingw47_32\include/GLES2/gl2.h:614:153:
> error: 'void __glewVertexAttribPointer(GLuint, GLint, GLenum,
> GLboolean, GLsizei, const GLvoid*)' redeclared as different kind of
> symbol In file included from src\UGGLWidget.cpp:1:0:
> ..\3rdPartyLibs\glew\include/GL/glew.h:13609:46: error: previous
> declaration of 'void (__attribute__((__stdcall__)) *
> __glewVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*)'
Last but not least the header and source file of the subclass. It's really just empty for now.
Source:
//UGGLWidget.cpp
#include "GL/glew.h"
#include "UGGLWidget.h"
UGGLWidget::UGGLWidget(QWidget *parent) : QGLWidget(parent) { ... }
Header:
//UGGLWidget.h
#ifndef UGGLWIDGET_H
#define UGGLWIDGET_H
#include <QGLWidget>
class UGGLWidget : public QGLWidget
{
Q_OBJECT
public:
explicit UGGLWidget(QWidget *parent = 0);
};
#endif // UGGLWIDGET_H
Oh, and maybe relevant parts from the .pro file
QT += core gui opengl
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
LIBS += -L$$quote(../3rdPartyLibs/glew/lib/) -lglew32
LIBS += -lopengl32 -lglu32
INCLUDEPATH += $$quote(../3rdPartyLibs/glew/include)
The following fixed my problem, this goes everywhere, where I include glew:
#include "GL/glew.h"
#define QT_NO_OPENGL_ES_2
Another option: building Qt5.0.1 from source with -opengl desktop during the configure step.
For some reason QT_OPENGL_ES_2 is defined in my Qt5.0.1 installation. Looking through the inlcudes from QGLWidget.h I found the following in QtCore/qconfig.h
#if defined(QT_OPENGL_ES_2) && defined(QT_NO_OPENGL_ES_2)
# undef QT_OPENGL_ES_2
#elif !defined(QT_OPENGL_ES_2)
# define QT_OPENGL_ES_2
#endif
This leads to inclusion of GLES2/gl2.h which doesn't get along with glew. Knowing that the issue was related to GLES2 I came across a bug report and a QtProject post.
If I understand correctly, then the provided QtSDK installer for Qt5.0.1 has been built such that GLES is enabled.
Have a good day,
~Moritz
Note that QT 4.8RC release notes say:
Including QtOpenGL will not work in combination with GLEW, as QGLFunctions will undefine GLEW's defines.
I'm using mingw32-make to compile a qt project that uses opengl, it compiles correctly and everything, but it spits countless warning messages of the form:
c:/qt3/include/qcolor.h:67: warning: inline function `int qGray(int, int,
int)' declared as dllimport: attribute ignored
For this particular instance, the function declaration is:
Q_EXPORT inline int qGray( int r, int g, int b )// convert R,G,B to gray 0..255
{ return (r*11+g*16+b*5)/32; }
My question is, why is it spitting all these warning? how can I silence them without silencing other legitimate warnings (i.e. warnings that are related directly to my code and could be potential problems)?
More importantly, why is mingw ignoring the dll import attribute in the first place?
I think Qt ought to only define Q_EXPORT (Q_DECL_EXPORT in Qt 4) to be the dllexport/import attribute if one of the following macros is defined, so make sure your makefiles or code that includes Qt headers (which eventually will include qglobal.h) aren't defining any of them: WIN32, _WIN32, __WIN32__, WIN64, _WIN64, __WIN64__. Or you can just define Q_EXPORT to be nothing in your compile (or preprocessor) flags, then Qt should skip defining it.