Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: rv2931 on January 18, 2009, 11:59:41 pm

Title: a warning Unused variable causes an error ?!?!? think it is a gcc configurationd
Post by: rv2931 on January 18, 2009, 11:59:41 pm
Hello, I have an error when I have a Warning : unused variable. I really don't understand why the compiler show that is a Warning and why it takes it for an error ??????

when I compil this code :

Code
#include <QApplication>
#include <QFont>
#include <QMainWindow>
#include "Graph.h"

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    QMainWindow *window=new QMainWindow();
    Graph* gr=new Graph(window);
    window->show();

    return app.exec();
}

I have this messages :
Quote
/home/rv/Bureau/Qt/CustomWidgets/Graph01/main.cpp||In function «int main(int, char**)»:|
/home/rv/Bureau/Qt/CustomWidgets/Graph01/main.cpp|10|attention : unused variable «gr»|
||=== Build finished: 1 errors, 0 warnings ===|

and when I compil this one :

Code
#include <QApplication>
#include <QFont>
#include <QMainWindow>
#include "Graph.h"

int main(int argc, char* argv[])
{
    QApplication app(argc, argv);
    QMainWindow *window=new QMainWindow();
    Graph* gr=new Graph(window);
    gr->y();
    window->show();

    return app.exec();
}

Quote
-------------- Build: Release in Graph01 ---------------

Compiling: main.cpp
Linking executable: release/Graph01
Output size is 20,09 KB
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings

I think it is due to a bad configuration of gcc in Code::Blocks but I don't see which option causes this behaviour

thanks

RV
Title: Re: a warning Unused variable causes an error ?!?!? think it is a gcc configurationd
Post by: Jenna on January 19, 2009, 12:15:48 am
Maybe this helps: http://forums.codeblocks.org/index.php/topic,9489.0.html (http://forums.codeblocks.org/index.php/topic,9489.0.html) .
Title: Re: a warning Unused variable causes an error ?!?!? think it is a gcc configurationd
Post by: rv2931 on January 19, 2009, 01:13:19 am
This behaviour could be due to the fact that the result of the compilation give "attention" in french and not Warning in a good english if I understand
...:o(

how to change that ???....
rv
Title: Re: a warning Unused variable causes an error ?!?!? think it is a gcc configurationd
Post by: Jenna on January 19, 2009, 01:24:42 am
This behaviour could be due to the fact that the result of the compilation give "attention" in french and not Warning in a good english if I understand
...:o(

how to change that ???....
rv

As I posted in the thread I linked to:
Quote
Because of this problem I use the envvar-plugin to set "LC_ALL" to "en_US.UTF-8" ("Settings.. -> Environment -> Environment variables").

I don't want to change the regexes, what's also possible, but much more work and of course more error-prone. And it depends on the translation, that is available for your compiler.
"Settings -> Compiler and debugger... -> Global compiler settings... -> Other settings -> Advanced options... -> Output parsing"
Title: Re: a warning Unused variable causes an error ?!?!? think it is a gcc configurationd
Post by: rv2931 on February 13, 2009, 02:12:20 pm
great Thanks It works

 :lol: