Что такое необъявленные ошибки идентификатора? Каковы общие причины и как их исправить?
Пример текстов ошибок:
- Для компилятора Visual Studio:
error C2065: 'cout' : undeclared identifier - Для компилятора GCC:
'cout' undeclared (first use in this function)
39
Решение
Чаще всего они приходят из-за того, что забывают включить заголовочный файл, содержащий объявление функции, например, эта программа выдаст ошибку «необъявленный идентификатор»:
Отсутствует заголовок
int main() {
std::cout << "Hello world!" << std::endl;
return 0;
}
Чтобы это исправить, мы должны включить заголовок:
#include <iostream>
int main() {
std::cout << "Hello world!" << std::endl;
return 0;
}
Если вы написали заголовок и включили его правильно, заголовок может содержать неправильный включить охрану.
Чтобы узнать больше, смотрите http://msdn.microsoft.com/en-us/library/aa229215(v=vs.60).aspx.
Переменная с ошибкой
Другой распространенный источник ошибки новичка возникает, когда вы неправильно написали переменную:
int main() {
int aComplicatedName;
AComplicatedName = 1; /* mind the uppercase A */
return 0;
}
Неправильный объем
Например, этот код выдаст ошибку, потому что вам нужно использовать std::string:
#include <string>
int main() {
std::string s1 = "Hello"; // Correct.
string s2 = "world"; // WRONG - would give error.
}
Использовать до объявления
void f() { g(); }
void g() { }
g не был объявлен до его первого использования. Чтобы это исправить, либо переместите определение g до f:
void g() { }
void f() { g(); }
Или добавить декларацию g до f:
void g(); // declaration
void f() { g(); }
void g() { } // definition
stdafx.h не сверху (специфично для VS)
Это зависит от Visual Studio. В VS нужно добавить #include "stdafx.h" перед любым кодом. Код до того, как он игнорируется компилятором, так что если у вас есть это:
#include <iostream>
#include "stdafx.h"
#include <iostream> будет проигнорировано Вам нужно переместить его ниже:
#include "stdafx.h"#include <iostream>
Не стесняйтесь редактировать этот ответ.
54
Другие решения
Рассмотрим похожую ситуацию в разговоре. Представьте, что ваш друг говорит вам: «Боб идет на ужин», а ты не представляешь, кто такой Боб. Вы будете в замешательстве, верно? Твой друг должен был сказать: «У меня есть коллега по работе по имени Боб. Боб подходит к обеду». Теперь Боб объявлен, и вы знаете, о ком говорит ваш друг.
Компилятор выдает ошибку «необъявленный идентификатор», когда вы пытаетесь использовать какой-то идентификатор (который будет именем функции, переменной, класса и т. Д.), И компилятор не видит объявления для него. То есть компилятор понятия не имеет, о чем вы говорите, потому что раньше его не видел.
Если вы получаете такую ошибку в C или C ++, это означает, что вы не сказали компилятору о том, что вы пытаетесь использовать. Объявления часто встречаются в заголовочных файлах, поэтому, скорее всего, это означает, что вы не включили соответствующий заголовок. Конечно, может случиться так, что вы просто не помните, чтобы объявить сущность вообще.
Некоторые компиляторы выдают более конкретные ошибки в зависимости от контекста. Например, пытаясь скомпилировать X x; где тип X не был объявлен с Clang скажет вам «неизвестное имя типа X«. Это гораздо полезнее, потому что вы знаете, что он пытается интерпретировать X как тип. Тем не менее, если у вас есть int x = y;, где y еще не объявлено, он скажет вам «использование необъявленного идентификатора y«потому что есть некоторая двусмысленность в том, что именно y может представлять.
12
У меня была такая же проблема с пользовательским классом, который был определен в пространстве имен. Я пытался использовать класс без пространства имен, вызывая ошибку компилятора «идентификатор» MyClass «не определен».
Добавление
using namespace <MyNamespace>
или используя класс, как
MyNamespace::MyClass myClass;
решил проблему.
5
В C и C ++ все имена должны быть объявлены перед использованием. Если вы попытаетесь использовать имя переменной или функции, которая не была объявлена, вы получите ошибку «необъявленный идентификатор».
Однако функции — это особый случай в C (и только в C), в котором вам не нужно сначала объявлять их. Компилятор C будет предполагать, что функция существует с числом и типом аргументов, как в вызове. Если фактическое определение функции не совпадает, вы получите еще одну ошибку. Этот особый случай для функций не существует в C ++.
Вы исправляете ошибки такого рода, проверяя, что функции и переменные объявлены до их использования. В случае printf вам нужно включить заголовочный файл <stdio.h> (или же <cstdio> в C ++).
Для стандартных функций я рекомендую вам проверить, например, этот справочный сайт, и найдите функции, которые вы хотите использовать. Документация для каждой функции говорит вам, какой заголовочный файл вам нужен.
4
Эти сообщения об ошибках
1.For the Visual Studio compiler: error C2065: 'printf' : undeclared identifier
2.For the GCC compiler: `printf' undeclared (first use in this function)
означает, что вы используете имя printf но компилятор не видит, где было объявлено имя, и, соответственно, не знает, что это значит.
Любое имя, используемое в программе, должно быть объявлено до ее использования. Компилятор должен знать, что обозначает имя.
В этом конкретном случае компилятор не видит объявление имени printf , Как мы знаем (но не компилятор) это имя стандартной функции C, объявленной в заголовке <stdio.h> в C или в заголовке <cstdio> в C ++ и размещены в стандарте (std::) и глобальный (::) (не обязательно) пространства имен.
Поэтому, прежде чем использовать эту функцию, мы должны предоставить объявление ее имени компилятору путем включения соответствующих заголовков.
Например
C:
#include <stdio.h>
int main( void )
{
printf( "Hello Worldn" );
}
C ++:
#include <cstdio>
int main()
{
std::printf( "Hello Worldn" );
// or printf( "Hello Worldn" );
// or ::printf( "Hello Worldn" );
}
Иногда причиной такой ошибки является простая опечатка. Например, давайте предположим, что вы определили функцию PrintHello
void PrintHello()
{
std::printf( "Hello Worldn" );
}
но в основном вы сделали опечатку и вместо PrintHello ты напечатал printHello с строчной буквы «р».
#include <cstdio>
void PrintHello()
{
std::printf( "Hello Worldn" );
}
int main()
{
printHello();
}
В этом случае компилятор выдаст такую ошибку, потому что он не видит объявление имени printHello, PrintHello а также printHello два разных имени, одно из которых было объявлено, а другое не объявлено, но используется в теле основного
3
Это похоже на использование функции без ее объявления. заголовочный файл будет содержать
функция printf (). Включите заголовочный файл в вашу программу, это решение для этого.
Некоторые пользовательские функции могут также вызывать ошибки, если они не были объявлены перед использованием. Если
это используется во всем мире без проб.
0
В большинстве случаев, если вы уверены, что импортировали данную библиотеку, Visual Studio поможет вам с IntelliSense.
Вот что сработало для меня:
Удостоверься что #include "stdafx.h" объявляется первым, то есть вверху всех ваших включений.
0
Я пытаюсь решить проблему. Я беру символы в качестве ввода и использую gets(). Но функция показывает вышеупомянутую ошибку.
Я не знаю, почему эта функция не работает. Пожалуйста, помогите мне найти вину. Я начинающий.
Как уже упоминалось, сообщение об ошибке:
Use of undeclared identifier 'gets'
Мой код на C ++:
#include <bits/stdc++.h>
using namespace std;
int main()
{
char line[1000];
bool open = true;
while (gets(line)) //***in this line gets() is showing error***
{
int len = strlen(line);
for (int i = 0; i < len; i++)
{
if (line[i] == '"')
{
if (open)
{
printf("``");
}
else
{
printf("''");
}
open = !open;
}
else
{
printf("%c", line[i]);
}
}
printf("n");
}
return 0;
}
3 ответа
Лучший ответ
Вот исправление.
#include <bits/stdc++.h>
using namespace std;
int main()
{
string line;
bool open = true;
while (getline(cin, line))
{
int len = line.length();
for (int i = 0; i < len; i++)
{
if (line[i] == '"')
{
if (open)
{
printf("``");
}
else
{
printf("''");
}
open = !open;
}
else
{
printf("%c", line[i]);
}
}
printf("n");
}
return 0;
}
1
Dabananda Mitra
12 Сен 2020 в 11:05
Gets () устарел, как уже упоминалось. Прочтите об этом здесь
Но давайте сначала рассмотрим основную причину того, почему вы получили ошибку. An
необъявленный идентификатор ‘получает’
Ошибка возникает из-за того, что компилятор не может найти объявление используемой вами функции. В вашем случае gets () определяется в stdio.h
Я также вижу, что вы используете std :: getline () как рекомендовано, и для этого вам необходимо включить заголовок string.
Взгляните на 2 ссылки, которые я упомянул, чтобы понять правильное использование.
1
pcodex
12 Сен 2020 в 11:07
std::gets устарел в C ++ 11 и удален из C ++ 14, это опасная функция, и ее никогда не следует использовать, хотя некоторые компиляторы все еще предоставляют его, похоже, что это не ваш случай, и это хорошо.
Вы должны использовать что-то вроде std::getline, обратите внимание, что для этого вам нужно, чтобы аргумент line был std::string.
string line;
//...
while (getline(cin, line)){
//...
}
В качестве альтернативы, если вам действительно нужен массив char, вы можете использовать {{X1} } вместо этого:
char line[1000];
//...
while(fgets(line, sizeof line, stdin)){
//remove newline character using strcspn
line[strcspn(line, "n")] = '';
//or with C++ std::replace
replace(&line[0], &line[1000], 'n', ''); //&line[1000] one past the array end
//...
}
Примечание:
Рассмотрите возможность не использовать using namespace std; и #include <bits/stdc++.h>, перейдите по ссылкам, чтобы получить подробную информацию.
4
anastaciu
13 Сен 2020 в 12:33
Nearly all TradingView scripts use custom, user-defined variables. A decent portion even uses custom functions. Those variables and functions prevent code repetition and make code easier to manage. But not so when they trigger the ‘undeclared identifier’ error. Let’s fix those errors!
IN THIS ARTICLE:
# Exploring TradingView’s ‘undeclared identifier’ error
TradingView Pine has a lot of built-in variables that return all kinds of information. And there are also plenty of functions that add all kinds of features to our indicator and strategy scripts. But we can also make our own variables and functions. That way we don’t have to perform the same calculations over and over again.
But while custom variables and functions often make our TradingView programming easier, at times they can also give a small headache. That latter for instance happens when we run into the ‘undeclared identifier’ error. When this error happens and our script already runs on the chart, we see ‘cannot compile script’ appear there:
This doesn’t help much since plenty of TradingView errors use that same message. But for the actual error information we’ll have to look in the Pine Editor’s console window.
There something like the following shows:
Processing script...
line 5: Undeclared identifier `emavalue`;
line 7: Undeclared identifier `plotColour`
Script 'Error example' has been saved
This has a lot more actionable information. Let’s see how we use this error information to fix the code problem.
# Fixing TradingView’s ‘undeclared identifier’ error
While the ‘undeclared identifier’ error message can be a bit annoying, the cause is often just a small mistake in our code. That makes fixing this error rather straightforward:
- Read the first line of the error message carefully. Note the line number as well as the incorrect variable or function name.
- Go to that line in the Pine Editor and locate the variable or function the error mentions.
- Look at the lines above the error line to see how you named that variable or function. Use that exact name to fix the error.
- Save the script. Repeat the steps if another ‘undeclared identifier’ error shows.
An identifier is the name we give a custom variable or function (TradingView Wiki, 2017). The identifier is whichever name appears to the left of = or => when we make our variable or function. That name can consists out of upper- and lowercase letters, an underscore (_), and numbers (although an identifier can’t start with a number).
The ‘undeclared identifier’ TradingView error can create an avalanche of error messages. But don’t feel intimidated by all that red in Pine Editor’s console window.
It’s just that when we make a mistake in one identifier, TradingView also triggers error for code that comes after it. So there might be 10 errors while in fact we’ve only made one mistake. So don’t worry if you see multiple errors. Just fix the first one and then save the script to see if the others still show.
Now let’s look at a few situations that trigger the ‘undeclared identifier’ error.
# Error example: incorrectly type a variable name
Likely the most common situation that gets us the ‘undeclared identifier’ TradingView error is when make a typing error with a variable name. This is also a bit annoying since we know what the variable name should be, it’s just that we typed it incorrectly.
An example indicator with that mistake is:
|
|
Processing script...
line 5: Undeclared identifier `emaVlue`;
line 7: Undeclared identifier `plotColour`
Script 'Error example' has been saved
Here we got the ‘undeclared identifier’ error for the emaVlue variable name. That should of course be emaValue, the variable we made in line 4.
And so to fix the error we replace emaVlue with emaValue in the 5th line:
plotColour = (close > emaValue) ? green : red
# Error example: incorrect capitalisation with a variable name
The name that we give our custom variable or function is case sensitive (TradingView Wiki, 2017). And so we need to refer to custom variables or functions with the exact same name as we used to create them.
But a capitalisation error is easily made. For instance:
|
|
Processing script...
line 5: Undeclared identifier `emavalue`;
line 7: Undeclared identifier `plotColour`
Script 'Error example' has been saved
Here the script errors because we used the emavalue identifier in line 5. Since we gave that variable the name of emaValue when we made it (line 4), we should also refer to it with the proper capitalisation.
And so to fix the ‘undeclared identifier’ error here we change the fifth line to:
plotColour = (close > emaValue) ? green : red
# Error example: executing a custom function without parentheses
When we make a TradingView function, we first declare its name, then list any parameters between parentheses (( and )), and end with the function’s code. If our custom function doesn’t use arguments, then that’s fine too. But to correctly refer to the function we do need to use parentheses after its name. When we don’t, we run into the ‘undeclared identifier’ TradingView error again.
Says we got an emaCustom() function but try to execute it as emaCustom:
|
|
Processing script...
line 9: Undeclared identifier `emaCustom`
Script 'Error example' has been saved
This example code runs into the ‘undeclared identifier’ error since we refer to the emaCustom() function as emaCustom. But without those missing parentheses (()) behind the function’s name, TradingView thinks we mean to use a variable. And the example indicator above doesn’t have an emaCustom variable.
To fix the problem we change line 9 to execute the function as emaCustom():
plot(series=emaCustom(), color=orange, linewidth=2)
# Error example: updating a variable before declaring it
There are two ways we can set our custom variable in TradingView. With = we make our variable and give it some value. Then if we later want to update its value, we use :=. But it has to be in that order – we first create a variable (with =), then we can update it (:=).
When we accidentally get the = and := order backwards, our code triggers the ‘undeclared identifier’ error message. For example:
|
|
Processing script...
line 4: Undeclared identifier `movAvg`;
line 6: Undeclared identifier `movAvg`
Script 'Error example' has been saved
Here we first tried to update the movAvg variable (line 4). Then later we attempt to declare it (line 6). This got TradingView confused: the ‘undeclared identifier’ error shows it cannot find movAvg when we try to update its value.
To fix the error here, we’ll have = and := swap places like so:
//@version=3
study(title="Error example", overlay=false)
movAvg = sma(close, 20)
plot(series=movAvg, color=orange, linewidth=2)
movAvg := ema(close, 10)
plot(series=movAvg, color=teal, linewidth=2)
# Error example: using a self-referencing variable without :=
Things get more complex when we got the ‘undeclared identifier’ error with a self-referencing variable. When a variable references its own previous value (like profit := profit[1] + todayProfit), that variable is called a self-referencing variable.
We need to do two things before we can use a self-referencing variable. First we have to create that variable with the = operator and set it to some default value (profit = 1.0). But at that point we can’t reference its own value yet! The second step is to update the variable to a new value with the := operator. At that point we can reference that variable’s previous bar values (TradingView Wiki, 2018).
But if we only use = with a self-referencing variable, we’ll run into the ‘undeclared identifier’ TradingView error. For example:
|
|
Processing script...
line 4: Undeclared identifier `barNumber`;
line 6: Undeclared identifier `barNumber`
Script 'Error example' has been saved
The problem here is that we try to do two things at once: create the barNumber variable but also update its value to include its previous bar value.
Instead we should first make barNumber with =. Only then can we update its value to include the previous bar value of barNumber. That means we fix the ‘undeclared identifier’ error when we change the code to:
|
|
# Error example: using a forward-referencing variable without :=
Another abstract situation that gets us the ‘undeclared identifier’ error message is with a forward-referencing variable. When we references a variable before it gets updated to a value, that variable is a forward-referencing variable.
There are two steps to make a forward-referencing variable work. First we create that variable with = and set it to some default value (stopPrice = 0.0). That code has to come before any references to that variable. Then we update its value with := to the value we actually intended it to hold (stopPrice := emaValue - 0.0020).
If we overlook a step and forward reference a variable before it got made with =, we’ll end up with the ‘undeclared identifier’ error. For instance:
|
|
Processing script...
line 4: Undeclared identifier `currentValue`;
line 5: Undeclared identifier `plusOne`;
line 7: Undeclared identifier `currentValue`
Script 'Error example' has been saved
The problem here is that we update the plusOne variable to the previous bar value of currentValue. But that happens before we create the currentValue variable. As such TradingView doesn’t understand what we’re talking about, and errors.
To make the forward reference in line 4 work, we need to make the currentValue variable before that line. We do that with the = operator. We can then update currentValue later, for which we use :=.
And so to fix the ‘undeclared identifier’ error here the code becomes:
|
|
# Summary
The ‘undeclared identifier’ error happens when TradingView cannot find the variable or function that we try to use. This happens when we mistype the name, including any capitalisation differences. The error also shows when we forget parentheses (( and )) with a function’s name.
Those coding mistakes are luckily easy to find and fix. But the ‘undeclared identifier’ error also shows in more complex situations. Those happen when we make a mistake with TradingView’s = and := operators. We can’t for instance update a variable (:=) before we make it (=). If we don’t follow that rule, we’ll get the error.
We also run into ‘undeclared identifier’ if, when creating the variable, we set its value to some previous bar value. Or when we refer to a variable before our script has executed the = operator to make that variable. To fix the error in these two situations we first make the variable with =. Only then can we fetch its value with errors. And if we later want to update the variable, we’ll use the := operator.
« All TradingView errors articles

“Use of undeclared identifier” Compilation error
Use of undeclared identifier error comes when compiler can’t find the declaration for an identifier. There are many possible causes for this error. The most common causes are that the identifier hasn’t been declared, the identifier is misspelled, the header where the identifier is declared is not included in the file, or the identifier is missing a scope qualifier. Some common issues and solutions
- Missing header
// For 'std::cout' we must include 'iostream' header #include <iostream> int main() { std::cout << "Hello world!" << std::endl; return 0; } - Misspelled variable
int main() { int varName; VarName = 1; /* mind the uppercase V */ return 0; } - Incorrect scope
This error can occur if your identifier is not properly scoped. When C++ Standard Library functions and operators are not fully qualified by namespace, or you have not brought the std namespace into the current scope by using a using directive, the compiler can’t find them. To fix this issue, you must either fully qualify the identifier names, or specify the namespace with the using directive.#include <string> int main() { std::string s1 = "Hello"; // Correct. string s2 = "world"; // WRONG - would give error. } - Use before declaration
void f() { g(); } void g() { }To fix it, either move the definition of g before f or add a declaration of g before f.
// Fix 1 void g() { } void f() { g(); } // Fix 2 void g(); // Declaration void f() { g(); } void g() { } // Definition - Missing closing quote
#include <iostream> int main() { // Fix this issue by adding the closing quote to "Aaaa" char *first = "Aaaa, *last = "Zeee"; std::cout << "Name: " << first << " " << last << std::endl; } - Preprocessor removed declaration
This error can occur if you refer to a function or variable that is in conditionally compiled code that is not compiled for your current configuration.#ifdef _DEBUG int condition; #endif int main() { std::cout << condition; // Fix by guarding references the same way as the declaration: // #ifdef _DEBUG // std::cout << condition; // #endif }
Sharing is Caring !
Page load link
Go to Top
This topic has been deleted. Only users with topic management privileges can see it.
I have created simple c++ based qt project.
I am using QMake version 3.1
Using Qt version 5.12.8 in /usr/lib/x86_64-linux-gnu
by default kit is coming like desktop
but i want to make simple widget application uisng qt c++.
so for that how to add kit that will not show below error.
but what i need
when i am running the project i am getting below error:
/home/mangal/JAYMOGAL/MYFIRST/part1/mainwindow.cpp:5: error: use of undeclared identifier ‘MainWindow’
Because you did not declare a class named ‘MainWindow’ maybe?
@Christian-Ehrlicher no this is not the problem because by default while we make new project this by default added by qt. i think this problem is related to kit. and i don’t know how to resolve kit related problem. i don’t know which kit i need to add for my simple c++ qt project .i have doubt is that in .pro file
that by default conains
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
@Qt-embedded-developer
.pro file has nothing to do with it. The error says it is on line #5 of the .cpp file. Why don’t you look at what the first 5 lines are?
@JonB for your reference the code for .cpp file is
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDebug>
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
}
MainWindow::~MainWindow()
{
delete ui;
}
so just tell me what you want to say about my line 5 problem. i want to understand it. i want to know the solution of it also.
@Qt-embedded-developer said in why i am getting this error: use of undeclared identifier ‘MainWindow’ ?:
#include «mainwindow.h»
#include «ui_mainwindow.h»
#include <QDebug>MainWindow::MainWindow(QWidget *parent)
So none of the #included files defines MainWindow. Only you have those files. If you want to understand why have a look in them. Maybe you need to force build to regenerate ui_mainwindow.h. Maybe you renamed the class in the .ui file. Maybe your mainwindow.h file is wrong.
@JonB i have not manually created any file. this is by default file added by qt
for your reference my mainwindow.h file contain this class defination
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <QMainWindow>
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
@Qt-embedded-developer
That looks as I would expect. So far I cannot see why you would get the error you reported. Assume there were no other errors reported.
What about the generated ui_mainwindow.h file from the .ui file, which is in the compilation output (usually Build-...) directory? Force a clean build; you could just delete all the files in that output (not your sources!) directory. Though that should not be the issue….
There is another mainwindow.h somewhere around which the compiler is using — seeing the other posts about the include path mess this is at least a very good option here…
@JonB i have deleted the all the files from output directory.
my compile output is:
10:55:52: Running steps for project part1...
10:55:52: Starting: "/usr/bin/x86_64-linux-gnu-qmake" /home/mangal/JAYMOGAL/MYFIRST/part1/part1.pro -spec linux-g++-64 CONFIG+=debug CONFIG+=qml_debug
10:55:52: The process "/usr/bin/x86_64-linux-gnu-qmake" exited normally.
10:55:52: Starting: "/usr/bin/make" -f /home/mangal/JAYMOGAL/MYFIRST/build-part1-Qt_5_12_8_System-Debug/Makefile qmake_all
make: Nothing to be done for 'qmake_all'.
10:55:52: The process "/usr/bin/make" exited normally.
10:55:52: Starting: "/usr/bin/make" -j2
/usr/lib/qt5/bin/uic ../part1/mainwindow.ui -o ui_mainwindow.h
x86_64-linux-gnu-g++ -c -m64 -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../part1 -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o main.o ../part1/main.cpp
x86_64-linux-gnu-g++ -m64 -pipe -g -std=gnu++11 -Wall -W -dM -E -o moc_predefs.h /usr/lib/x86_64-linux-gnu/qt5/mkspecs/features/data/dummy.cpp
x86_64-linux-gnu-g++ -c -m64 -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../part1 -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o mainwindow.o ../part1/mainwindow.cpp
/usr/lib/qt5/bin/moc -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB --include /home/mangal/JAYMOGAL/MYFIRST/build-part1-Qt_5_12_8_System-Debug/moc_predefs.h -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -I/home/mangal/JAYMOGAL/MYFIRST/part1 -I/usr/include/x86_64-linux-gnu/qt5 -I/usr/include/x86_64-linux-gnu/qt5/QtWidgets -I/usr/include/x86_64-linux-gnu/qt5/QtGui -I/usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/include/c++/9 -I/usr/include/x86_64-linux-gnu/c++/9 -I/usr/include/c++/9/backward -I/usr/lib/gcc/x86_64-linux-gnu/9/include -I/usr/local/include -I/usr/include/x86_64-linux-gnu -I/usr/include ../part1/mainwindow.h -o moc_mainwindow.cpp
x86_64-linux-gnu-g++ -c -m64 -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../part1 -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++-64 -o moc_mainwindow.o moc_mainwindow.cpp
x86_64-linux-gnu-g++ -m64 -o part1 main.o mainwindow.o moc_mainwindow.o -L/usr/X11R6/lib64 /usr/lib/x86_64-linux-gnu/libQt5Widgets.so /usr/lib/x86_64-linux-gnu/libQt5Gui.so /usr/lib/x86_64-linux-gnu/libQt5Core.so /usr/lib/x86_64-linux-gnu/libGL.so -lpthread
10:55:59: The process "/usr/bin/make" exited normally.
10:55:59: Elapsed time: 00:07.
but still i get this warning in issue window:
mainwindow.h:10: error: expected class name
@Qt-embedded-developer said in why i am getting this error: use of undeclared identifier ‘MainWindow’ ?:
but still i get this warning in issue window:
mainwindow.h:10: error: expected class name
I don’t know what the «issue» window is, maybe this is code model warning not from compiler?
@JonB what to do to stop code model warning in qt creator ?
@Qt-embedded-developer said in why i am getting this error: use of undeclared identifier ‘MainWindow’ ?:
what to do to stop code model warning in qt creator ?
Disable the Clang plug-in (in Help/About Plugins…)
@jsulm when i am disable it my building of project process not get stop. it continuously running.
@Qt-embedded-developer Clang plug-in has actually nothing to do with the build.
Try complete rebuild: delete build folder, run qmake and then build.


