Здравствуйте.
Qt Creator выдаёт ошибку в библиотеке stdlib.h. На Неё же в том же месте ругается и KDevelop. Ошибка следующая:
expected unqualified-id before string constant stdlib.h:35
В программе связывает со строкой
#include <stdlib.h>
Система Slackware 13.0.
Среды: Qt Creator 1.2.1, KDevelop 3.9.91
Решено: Ошибка в stdlib.h
Модератор: Модераторы разделов
-
NickLion
- Сообщения: 3408
- Статус: аватар-невидимка
- ОС: openSUSE Tumbleweed x86_64
Re: Решено: Ошибка в stdlib.h
А если компилить просто g++, эта ошибка тоже есть? В 35 строчке стоит макрос, который заменяться должен на `extern "C" {`... т.е. ничего страшного. Покажите что-ли код Вашей программы. Думаю причина всё же в ней.
-
Erok
- Сообщения: 7
- ОС: Slackware 13.0
Re: Решено: Ошибка в stdlib.h
Ошибка только в main.cpp. Привожу его.
Код: Выделить всё
#include <QCoreApplication>
#include "lab3.h"
#include "stdafx.h"
#include <stdlib.h>
#include <iostream>
#include <ctime>
using namespace std;
int main(int argc, char** argv)
{
QCoreApplication app(argc, argv);
//lab3 foo;
desant t1;
desant t2;
desant t3(t2);
desant t4(2, 3, 2, 1, 200);
desant t5(6, 4, 1, 0, 145);
jumper j;
cout << "\nFirst random object:";
t1.show();
cout << "\nSecond random object:";
t2.show();
cout << "\nCopy of second random object:";
t3.show();
cout << "\n1st objact with parametrs:";
t4.show();
cout << "\n2st objact with parametrs:";
t5.show();
cout << "\nTis is the beter object";
j.jshow();
return 0;
}-
NickLion
- Сообщения: 3408
- Статус: аватар-невидимка
- ОС: openSUSE Tumbleweed x86_64
Re: Решено: Ошибка в stdlib.h
Едем дальше, что в stdafx.h лежит? Пустая строка в конце есть?
-
Erok
- Сообщения: 7
- ОС: Slackware 13.0
Re: Решено: Ошибка в stdlib.h
Пустая строка есть. Приведу сразу все файлы.
stdafx.h:
lab3.h:
lab3.cpp:
desant.h:
stdafx.h:
Код: Выделить всё
// stdafx.h: включаемый файл для стандартных системных включаемых файлов
// или включаемых файлов для конкретного проекта, которые часто используются, но
// не часто изменяются
//
#pragma once
//#include "targetver.h"
#include <stdio.h>
//#include <tchar.h>
// TODO. Установите здесь ссылки на дополнительные заголовки, требующиеся для программыlab3.h:
Код: Выделить всё
#ifndef lab3_lab3_H
#define lab3_lab3_H
#include <QtCore/QObject>
#pragma once
class desant
{
int fkoordx;
int fkoordy;
int fname;
int fvertspeed;
int ftime;
int fclass; //0 - десантник, 1 - боевая машина
public:
desant();//конструктор по умолчанию
desant(desant &a);//конструктор копирования
desant(int akoordx, int akoordy, int avertspeed, int aclass, int aname);//конструктор с параметрами
virtual int show();//вывод
~desant();
};
class jumper: public desant
{
int jkoordx;
int jkoordy;
int jname;
int jvertspeed;
int jtime;
public:
jumper();//конструктор по умолчанию
virtual int jshow();//вывод
~jumper();
}
#endif // lab3_lab3_Hlab3.cpp:
Код: Выделить всё
#include "lab3.h"
#include "stdafx.h"
#include<stdlib.h>
#include<iostream>
using namespace std;
desant::desant()
{
fkoordx=rand()%100;
fkoordy=rand()%100;
fname=rand();
fvertspeed=1;
fclass=rand()%2+1;
}
desant::desant(desant &a)
{
fkoordx=a.fkoordx;
fkoordy=a.fkoordy;
fname=a.fname;
fvertspeed=a.fvertspeed;
fclass=a.fclass;
}
desant::desant(int akoordx, int akoordy, int avertspeed, int aclass, int aname)
{
fkoordx=akoordx;
fkoordy=akoordy;
fname=rand()%aname+5;
fvertspeed=avertspeed;
fclass=aclass;
}
int desant::show()
{
cout << "\nPersonal number - " << fname << "\n";
if(fclass) cout << "This man\n"; else cout << "This is warmachine\n";
cout << "X coordinate =" << fkoordx << "\nY coordinate =" << fkoordy << "\n";
cout << "Vertical speed = " << fvertspeed << "\n";
return 0;
}
desant::~desant()
{
cout << "DESTRUCTION";
}
jumper::jumper()
{
jkoordx=rand()%100;
jkoordy=rand()%100;
jname=rand();
jvertspeed=2;
}
int jumper::jshow()
{
cout << "\nPersonal number - " << jname << "\n";
cout << "This great(!) man\n";
cout << "X coordinate =" << jkoordx << "\nY coordinate =" << jkoordy << "\n";
cout << "Vertical speed = " << jvertspeed << "\n";
return 0;
}desant.h:
Код: Выделить всё
#pragma once
class desant
{
int fkoordx;
int fkoordy;
int fname;
int fvertspeed;
int ftime;
int fclass; //0 - десантник, 1 - боевая машина
public:
desant();//конструктор по умолчанию
desant(desant &a);//конструктор копирования
desant(int akoordx, int akoordy, int avertspeed, int aclass, int aname);//конструктор с параметрами
int show();//вывод
~desant();
};-
NickLion
- Сообщения: 3408
- Статус: аватар-невидимка
- ОС: openSUSE Tumbleweed x86_64
Re: Решено: Ошибка в stdlib.h
В объявлении class jumper забыли в конце точку с запятой.
-
Erok
- Сообщения: 7
- ОС: Slackware 13.0
Re: Решено: Ошибка в stdlib.h
Спасибо большое! Помогло))