Error expected initializer before cout

Error expected initializer before cout I am new to c++, my second day actually. I typed up this code from the tutorial site I am using, http: //newdata.box.sk/bx/c/htm/ch02.htm . I get an error 6 C:C++ch2l2.2.cpp expected `; ‘ before «cout» Whenever I try to compile it. This is a serious issue to me, I […]

Содержание

  1. Error expected initializer before cout
  2. Error expected initializer before cout
  3. Error expected initializer before cout
  4. G++ errors
  5. User Tools
  6. Site Tools
  7. Table of Contents
  8. Common G++ Errors
  9. Summary
  10. Weird Errors
  11. Bad Code Sample
  12. ‘cout’ was not declared in this scope
  13. ‘printf’ was not declared in this scope
  14. Cannot Pass Objects of non-POD Type
  15. Invalid Use of Member
  16. Request for Member ‘Foo’ in ‘Bar’, which is of non-class type ‘X’
  17. Undefined Reference to V Table
  18. Error expected initializer before cout

Error expected initializer before cout

I am new to c++, my second day actually. I typed up this code from the tutorial site I am using, http: //newdata.box.sk/bx/c/htm/ch02.htm .

I get an error
6 C:C++ch2l2.2.cpp expected `; ‘ before «cout»
Whenever I try to compile it.

This is a serious issue to me, I have searched google for an hour and have not found out yet a fix. I know you will tell me, Don’t use iostream.h!, However when I don’t I get MORE errors.

One more thing, is «n» the same as endl?

#include
int main()
<
cout Last edited on

Wow, I am dumb. I didn’t even think to look BEFORE the cout that was on line 6.

Thanks for the Code::Blocks idea, I am downloading it now. I had spent an hour trying to find a good compiler yesterday, and finally gave up when Dev-C++ worked for me.

The alternative thing there, would that work for all objects? I would assume yes but confirmation would be nice.

Wow, I am dumb. I didn’t even think to look BEFORE the cout that was on line 6.

No worries, took me a bit to get used to the compiler messages also.

Apparently, the last version of Dev (4.9.9?) hasn’t been updated in about 5 years (and that’s beta to boot).

DevC++ did go on to have something to do with wxWidgets I think (another compiler I’ve seen recommended here), but I haven’t played around with it. CB has an addon for wxWidgets I see though, but still haven’t gotten to it. I’m pretty partial to CodeBlocks. there’s tons of options and customization and compiler seems to be (in my limited experience) good.

The alternative thing there, would that work for all objects? I would assume yes but confirmation would be nice.

Yea, pretty much. It’s all one large statement, and the statement doesn’t end until a ; is reached (or a closing bracket >, as the brackets <> denote a series of statements). The concept is called whitespace. Spaces, lines, tabs, etc etc, they don’t matter. This is perfectly legal:

. which is the exact equivelant to:

It boils down to readability and coding style.

edit: note that there are a few subtleties to the closing line/closing bracket things. Classes, for instace, require a closing line at the end of the bracket:

Источник

Error expected initializer before cout

I’m writing a class with an array and I’m supposed to calculate the average of some entered grades outside the class and in the main but I get the error
Expected Initializer before ‘.’ token

I’m not to sure what to do or i even did the class right
Please help!

What if I promised you $1000, but then just walk away, leaving you empty handed?
You make a promise on line 24, but you don’t keep it.

The error is on line 44. Please explain this code:
float gradeAverage.getGrade();

Line 44 looks like a nice prototype, but what is it doing in the middle of the program?

In the function «getGrade()» Why are you printing the array when you should be returning something from the array. In this case the «getGrade()» function should have a parameter the represents the element of the array that you need.

As you have it «float getGrade ()» would be better named «void printGrades ()».

Hope that helps,

I know that i shouldn’t be printing the there but the question was my teacher gave me was this
Write a class called Student that contains a property called grades that can store a
maximum of 10 grades. Create a setter and a getter method. The setter method
will take no parameters and return no parameters. Instead, within the setter
method you must construct a loop that will ask the user to enter 10 grades. The
getter method will simply print the 10 grades; so, it will take no and return no
parameters. Yes, that is a misnomer; this is because passing and returning arrays
has not been covered yet. Create another method called computeAverage that
return the average of all the grades. Create another method called
minimumGrade that returns the minimum grade the student received.

He knows it’s a misnomer but he wants us to do it anyway.
He hasn’t covered it yet so I was just looking it up but nothing I find helps

Now that I see what is required I will take a look tomorrow and see what I can do.

Источник

Error expected initializer before cout

I keep receiving this error, nothing I do helps it’s in
line 11, while (again == ‘Y’ || again == ‘Y’) //begins while loop

You do have something essential missing, the braces around the body of the function.
See: http://www.cplusplus.com/doc/tutorial/program_structure/

Once you have followed that advice you will get a different error: What is the «again»?

PS. Please edit your post to use code tags.
See: http://www.cplusplus.com/articles/jEywvCM9/
Pay attention to indentation too. It can help reading your code.

When I put a brace < before the while statement I end up with a 10 more errors?
This is my first programming class I have never done anything like this and I’m frustrated.

These are the instruction for the program, I have to include all of this and I don’t even know if I have included all of it.

Create the following program which converts Fahrenheit to Celsius. Your program must have the following functions:
•Read integer Fahrenheit temperatures from the user. You need to check whether the input is the correct one or not. If the user enters the incorrect number, ask it again.
•Use the formula: Celsius = (Fahrenheit – 32) * 5.0 / 9.0
•The output Celsius should be a floating point with two digits of precision.
•The Celsius temperatures should be displayed with a sign of positive or negative.
•The program should ask the user to continue or not. If the user wants to do the conversion again, use repetitive statements such as DO WHILE, FOR, or IF THEN ELSE to do the conversion again.
•Add comments to explain the functions of the program.

I have been working on this and this is what I now have, with a set of new errors.
which are [Error] ‘setprecision’ cannot be used as a function
and [Error] ‘setw’ cannot be used as a function

Hi dreaweiss, welcome to the forum.

I’ll outline the problems with your code:

1.) On line 4, you declare three variables. Two of them, namely ‘setprecision’ and ‘setw’ are also the names of functions found in the ‘std’ namespace. Normally, one would access these functions by using the scope-resolution operator like so: std::setprecision and std::setw . However, since you’ve elected to use using namespace std; in global scope, the compiler thinks that your function calls on lines 28 and 30 are actually attempts to treat your variables on line 4 as functions.

The way to fix this is to simply remove the offending variables on line 4, since you aren’t even using them for anything. Your fourth line of code should therefore only declare ‘again’.

2.) Technically, line 4 shouldn’t just declare ‘again’, but also define / initialize it. If you do not give ‘again’ an initial value, you’re invoking undefined behavior on line 5 when you enter the while-loop because ‘again’ contains garbage, and you’re attempting to access it. Fix this by initializing ‘again’ on line 4 (so that it may enter the while-loop).

In addition, ‘again’ shouldn’t be an int , it should be a char .

3.) There’s a discrepancy in the condition of your while-loop on line 5. What you probably meant to write was while (again == ‘y’ || again == ‘Y’ ) , not while (again == ‘Y’ || again == ‘Y’ ) .

4.) The while-loop on line 5 has no body. The semi-colon (‘;’) immediately following the parentheses on line 5 is the cause of this. You will have to remove the semi-colon and add some braces (‘<‘ and ‘>‘) around all of the code that should be part of the while-loop’s body.

That should be a good start. I’ve appended this basic code as a guide:

Xismn,
Thank you
I followed all of your directions, I no longer have any errors in my code but when I run it the black boxes opens and nothing is in it. It should be asking for a Fahrenheit degree and then give it to me Celsius, and then ask if I want to convert more values. I don’t know where to go from here, with no errors showing up
This is what have now

Источник

G++ errors

User Tools

Site Tools

Table of Contents

Common G++ Errors

Summary

This is a guide to help you CS35ers make sense of g++ and its often cryptic error messages.
If you discover an error not listed here feel free to edit this wiki,
or send your error along with source code and an explanation to me — grawson1@swarthmore.edu

Weird Errors

If you are getting strange compiler errors when your syntax looks fine, it might be a good idea to check that your Makefile is up to date
and that you are including the proper .h files. Sometimes a missing > or ; or ) will yield some scary errors as well.
Lastly, save all files that you might have changed before compiling.

Bad Code Sample

What’s wrong with the following code? (Hint: there are two errors)

When compiled this yields:

junk.cpp:9: error: expected initializer before ‘
junk.cpp:13: error: expected primary-expression before ‘return ‘
junk.cpp:13: error: expected `;’ before ‘return ‘
junk.cpp:13: error: expected primary-expression before ‘return ‘
junk.cpp:13: error: expected `)’ before ‘return ‘

First, the parameters of the for loop need to be separated by semicolons, not commas.

Now look at this sample output of the corrected code:

-1208637327
-1208637326
-1208637325
-1208637324
-1208637323
-1208637322

Why the weird values? Because we never initialized foo before incrementing it.

‘cout’ was not declared in this scope

Two things to check here:

to your list of headers? (2) Did you add

after your #includes?

‘printf’ was not declared in this scope

to your list of headers. Note if you are coming from C programming, adding #include is preferred in C++ over #include .

Cannot Pass Objects of non-POD Type

junk.cpp:8: warning: cannot pass objects of non-POD type ‘struct std::string’ through ‘…’; call will abort at runtime
junk.cpp:8: warning: format ‘%s’ expects type ‘char*’, but argument 2 has type ‘int ‘

What this usually means is that you forgot to append .c_str() to the name of your string variable when using printf.
This error occurred when trying to compile the following code:

Simply appending to .c_str() to “foo” will fix this:

The reason you got this error is because printf is a C function and C handles strings differently than C++

Invalid Use of Member

junk.cpp:8: error: invalid use of member (did you forget the ‘&’ ?)

What this usually means is that you forget to add () to the end of a function call.
Ironically, every time I see this it is never because I forgot the ‘&’. This error occurred when trying to compile the following code:

Simply adding the open and close parentheses () will take care of this for you:

Request for Member ‘Foo’ in ‘Bar’, which is of non-class type ‘X’

trycredit.cpp:86: error: request for member ‘print’ in ‘card’, which is of non-class type ‘CreditCard* ‘

What this usually means is that you are using a ‘.’ between the class pointer and the function you are trying to call. Here is an example from the CreditCard lab:

Since card is a CreditCard* we need → rather than . Fixed:

Undefined Reference to V Table

This error usually means you need to add a destructor to your myClass.cpp/myClass.inl code. If you don’t want to implement a real destructor at this point, you can write something like this:

So long as the destructor exists, you should now be able to compile fine. Of course, implement a real destructor at a later point.

Источник

Error expected initializer before cout

prog3.cpp:10:1: error: expected initializer before ‘int’
int main ()
^
this is what i get when i run this program please any help regarding this it will be much appreciated and please tell me if i made this program workable like with boolean expression if the function and prototype are well declared and performing together

/*This program ask user to input Hour, Minute and seconds and if the user
put in the valid format it runs othervise it says error. */

bool readTime(int &hours, int &minutes, int &seconds)

int main ()
<
int h,m,s;
if(readTime(h,m,s)) <
printf(«%2d:%2d:%2d» h, m, s);
return 0;
>
>

printf(«please enter time in format 09:30:50n»);
int count = scanf(«%2d:%2d:%2d», &hh, &mm, &ss);
>
// did they get the right format?
if (count !=3) <
printf(«Invalid formatn»);
return false;
>
// is the number of hours correct?
if ((hh 23)) <
printf(«Invalid hour %d n», hh);
return false;
>
//is number of minutes wrong?
if ((mm 0)) <
printf(«Invalid Minutes %d n», mm);
return false;
>
//is number of seconds wrong?
if ((ss 0)) <
printf(«Invalid seconds %d n», mm);
return false;
>

now this is what i get after doing your instructions

prog3.cpp: In function ‘int main()’:
prog3.cpp:14:28: error: expected ‘)’ before ‘h’
printf(«%2d:%2d:%2d» h, m, s);
^
prog3.cpp:14:35: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
printf(«%2d:%2d:%2d» h, m, s);
^
prog3.cpp: In function ‘bool readTime(int&, int&, int&)’:
prog3.cpp:24:8: warning: unused variable ‘count’ [-Wunused-variable]
int count = scanf(«%2d:%2d:%2d», &hh, &mm, &ss);
^
prog3.cpp:25:4: warning: no return statement in function returning non-void [-Wreturn-type]
>
^
prog3.cpp: At global scope:
prog3.cpp:27:4: error: expected unqualified-id before ‘if’
if (count !=3) <
^
prog3.cpp:32:4: error: expected unqualified-id before ‘if’
if ((hh 23)) <
^
prog3.cpp:37:4: error: expected unqualified-id before ‘if’
if ((mm 0)) <
^
prog3.cpp:42:4: error: expected unqualified-id before ‘if’
if ((ss 0)) <
^
prog3.cpp:47:1: error: expected declaration before ‘>’ token
>
^

You have extra braces.

You will find it extremely helpful to
1. Indent your code consistently. Use an editor which does this for you.
2. Type the closing brace at the same type you type the opening brace. Use an editor which does this for you.

Here is a «fixed» version. (there’s still some issues, but it will compile with warnings.)

i run your program but then i see this issue it will be helpful if i get perfectly running program so that i know for my upcoming exam how to make this type of program run. I am currently preparing for my exam. hope to see some help from you guys out there

In function ‘int main()’:
9:26: error: expected ‘)’ before ‘h’
9:33: warning: format ‘%d’ expects a matching ‘int’ argument [-Wformat=]
In function ‘bool readTime(int&, int&, int&)’:
41:1: warning: control reaches end of non-void function [-Wreturn-type]

This line :
printf( «%2d:%2d:%2d» h, m, s);

Should be :
printf( «%2d:%2d:%2d» , h, m, s); // An extra comma (,)

thank you for the help but why am i facing problem like this?

progs3.cpp:41:1: warning: control reaches end of non-void function [-Wreturn-type]
>
^

Notice that the compiler provides you with the location of any errors that it encounters.

Line 9, column 26 — usually there’s a filename, too. There’s a missing comma (I missed it, apologies.)

If the problem is a syntax error, the compiler will report the error no earlier than it appears. Look at the location of the first error and then look backwards towards the beginning of the file until you find it.

thank you for the help its so much appreciated and helpful for my upcoming exam and future programming errors. but can you help me with my issue on line 41?

Источник

Аманта

0 / 0 / 0

Регистрация: 14.02.2019

Сообщений: 6

1

14.02.2019, 21:14. Показов 21254. Ответов 3

Метки нет (Все метки)


Подскажите, пожалуйста, я только начинаю изучать с++. в программе:

C++
1
2
3
4
5
6
7
8
9
10
#include <iostream>
using namespace std;
Int main()
Int s
{
cin >> s;
cout << s;
cin get();
return 0;
}

Возникает ошибка: expected initializer before ‘int’
int s
^~~
Как её исправить? Все варианты уже перепробовала. Заранее спасибо.

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Байт

Диссидент

Эксперт C

27209 / 16962 / 3749

Регистрация: 24.12.2010

Сообщений: 38,147

14.02.2019, 21:18

2

C++
1
2
3
4
5
6
7
8
9
10
include <iostream>
using namespace std;
int main()
{
int s;
cin >> s;
cout << s;
cin get();
return 0;
}

В Си(++) регистр букв имеет значение. int — Int — вещи разные.
Ну и синтаксис…



1



324 / 217 / 105

Регистрация: 12.02.2019

Сообщений: 944

14.02.2019, 21:18

3

Int что за тип? int



0



0 / 0 / 0

Регистрация: 14.02.2019

Сообщений: 6

16.02.2019, 09:20

 [ТС]

4

Спасибо огромное! Вчё получилось!



0



Hey everyone I am a newbie and would love some help. I got the book called C++ without fear by Brian Overland and I’m following along all the examples but for some reason this happens:

E:portableappsDev-Cpp PortableAppdevcppmain.cpp In function int main(int, char**)':
9 E:portableappsDev-Cpp PortableAppdevcppmain.cpp expected
;’ before «cout»
E:portableappsDev-Cpp PortableAppdevcppMakefile.win [Build Error] [main.o] Error 1

The example in the book says to write the following code and save it then compile and run it:

#include <iostream>
using namespace std;
int main() {
cout << "I am Blaxxon," <<endl;
cout << "the godlike computer." <<endl;
cout << "Fear me! <<endl;

system("PAUSE");
return 0;
}

it works fine sometimes in other times I have to write it this way:

#include <iostream>
using namespace std;
int main(int argc, char *argv[]) {
cout << "I am Blaxxon," <<endl;
cout << "the godlike computer." <<endl;
cout << "Fear me! <<endl;

system("PAUSE");
return EXIT_SUCCESS;

otherwise it would show me some errors, which I think is a compiler bug; Dev-C++ portable Beta version.

Anyways the book states that if these characters << endl; are omitted, the program would print

I am Blaxxon, the godlike computer. Fear me!

In a single line, of course. So I try it but I get this error:

E:portableappsDev-Cpp PortableAppdevcppprint2.cpp In function int main(int, char**)':
9 E:portableappsDev-Cpp PortableAppdevcppprint2.cpp expected
;’ before «cout»
E:portableappsDev-Cpp PortableAppdevcppMakefile.win [Build Error] [print2.o] Error 1

It doesn’t print anything in a single like it just show me a systax error. No clue what it is. Any help please.

  • Forum
  • Beginners
  • expected initializer before «std»

expected initializer before «std»

#include <iostream>

int main()

{

int n,a,b,c,s

std::cout<<«n=»; std::cin>>n;

a=n/100;

b=n/10%10;

c=n%10;

s=a+b+c;

std::cout<<«The digits sum is:»<<s;

return 0;

}

What did I do wrong here? It tells me that the «std::cout<<«n=»; std::cin>>n;» line is wrong and says «expected initializer before «std»».Write your question here.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>

int main()
{
    int n,a,b,c,s; //was missing a semicolon here

    std::cout << "n = ";
    std::cin >> n;

    a = n / 100;
    b = n / 10 % 10;
    c = n % 10;
    s = a + b + c;

    std::cout << "nThe digits sum is: " << s;

    return 0;
}

Last edited on

int n,a,b,c,s has no semi-colon.

PLEASE learn to use code tags, it makes it easier to read your code.

You can edit your post and add the tags.

http://www.cplusplus.com/articles/jEywvCM9/

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <iostream>

int main()

{



   int n, a, b, c, s

   std::cout << "n="; std::cin >> n;

   a = n / 100;

   b = n / 10 % 10;

   c = n % 10;

   s = a + b + c;

   std::cout << "The digits sum is:" << s;

   return 0;

}

Topic archived. No new replies allowed.

Table of Contents

Common G++ Errors

Summary

This is a guide to help you CS35ers make sense of g++ and its often cryptic error messages.

If you discover an error not listed here feel free to edit this wiki,
or send your error along with source code and an explanation to me — grawson1@swarthmore.edu

Weird Errors

If you are getting strange compiler errors when your syntax looks fine, it might be a good idea to check that your Makefile is up to date
and that you are including the proper .h files. Sometimes a missing } or ; or ) will yield some scary errors as well.
Lastly, save all files that you might have changed before compiling.

Bad Code Sample

What’s wrong with the following code? (Hint: there are two errors)

#include<iostream>
using namespace std;
 
int main(){
 
  int foo;
 
  for(int i = 0, i<100, i++) {
    foo++;
    cout << foo << endl;
  }
  return 0;
}

When compiled this yields:

junk.cpp:9: error: expected initializer before '<' token

junk.cpp:13: error: expected primary-expression before 'return

junk.cpp:13: error: expected `;' before 'return

junk.cpp:13: error: expected primary-expression before 'return

junk.cpp:13: error: expected `)' before 'return

First, the parameters of the for loop need to be separated by semicolons, not commas.

for(int i = 0; i<100; i++) {
    foo++;
    cout << foo << endl;
  }

Now look at this sample output of the corrected code:

-1208637327

-1208637326

-1208637325

-1208637324

-1208637323

-1208637322

Why the weird values? Because we never initialized foo before incrementing it.

 int foo = 0;

‘cout’ was not declared in this scope

Two things to check here:

(1) Did you add

 #include<iostream> 

to your list of headers?
(2) Did you add

 using namespace std; 

after your #includes?

‘printf’ was not declared in this scope

Add

 #include<cstdio> 

to your list of headers. Note if you are coming from C programming, adding
#include<cstdio> is preferred in C++ over #include <stdio.h>.

Cannot Pass Objects of non-POD Type

junk.cpp:8: warning: cannot pass objects of non-POD type 'struct std::string' through '…'; call will abort at runtime

junk.cpp:8: warning: format '%s' expects type 'char*', but argument 2 has type 'int

What this usually means is that you forgot to append .c_str() to the name of your string variable when using printf.

This error occurred when trying to compile the following code:

int main(){
 
  string foo = "dog";
  printf("This animal is a %s.n",foo);
  return 0;
}

Simply appending to .c_str() to “foo” will fix this:

printf("This animal is a %s.n",foo.c_str());

The reason you got this error is because printf is a C function and C handles strings differently than C++

Invalid Use of Member

junk.cpp:8: error: invalid use of member (did you forget the '&' ?)

What this usually means is that you forget to add () to the end of a function call.

Ironically, every time I see this it is never because I forgot the ‘&’.
This error occurred when trying to compile the following code:

int main(){
 
  string foo = "dog";
  printf("This animal is a %s.n",foo.c_str);
 
  return 0;
}

Simply adding the open and close parentheses () will take care of this for you:

printf("This animal is a %s.n",foo.c_str());

Request for Member ‘Foo’ in ‘Bar’, which is of non-class type ‘X’

trycredit.cpp:86: error: request for member 'print' in 'card', which is of non-class type 'CreditCard*

What this usually means is that you are using a ‘.’ between the class pointer and the function you are trying to call.
Here is an example from the CreditCard lab:

void useCard(CreditCard *card, int method) {
  //Used to access the methods of the class
 
  if (method==1) {
    card.print();
  }

Since card is a CreditCard* we need → rather than . Fixed:

  if (method==1) {
    card->print();
  }

Undefined Reference to V Table

This error usually means you need to add a destructor to your myClass.cpp/myClass.inl code.
If you don’t want to implement a real destructor at this point, you can write something like this:

myClass::~myClass(){}

So long as the destructor exists, you should now be able to compile fine. Of course,
implement a real destructor at a later point.

  • Печать

Страницы: [1]   Вниз

Тема: Ошибка при попытке использовать iostream  (Прочитано 1548 раз)

0 Пользователей и 1 Гость просматривают эту тему.

Оффлайн
tetramin

Добрый день.

Я пытался написать программу типа хелловорлд.
Компилятор показывет столько ошибок, что они не помещаются на стандартный вывод.
Думая, что ошибка где-то либо в using namespace std, или в std::cout << …, я решил попробовать оставить только это:

#include <iostream>

int main ()
{
return 0;
}


Файл iostream, вместе со всеми, прописанными в нём, есть в /usr/include/c++/4.4/bits
Как я понял в итоге, проблема именно в этих файлах.

Ребята, в чём у меня проблема. Пробовал переустанавливать g++. Не помогает.


Оффлайн
__v1tos

sudo apt-get install build-essential
Как компилируете?

AMD Phenom II 945, GA-MA790GPT-UD3H (HD 3300), 5 GiB ram


Оффлайн
Mam(O)n

Подозреваю, что компилируешь не с помощью g++. Ибо УМВР.


Оффлайн
tetramin

build-essential у меня установлен

А компилирую так:

$ g++ -o hiall hiall.cpp

Я тут ещё попробовал math.h включить:
Часть кода:

/usr/include/c++/4.4/stdio.h:140: error: expected initializer before ‘__getStream’
/usr/include/c++/4.4/stdio.h:149: error: expected initializer before ‘clearerr’
/usr/include/c++/4.4/stdio.h:150: error: expected initializer before ‘fclose’
/usr/include/c++/4.4/stdio.h:151: error: expected initializer before ‘fflush’
/usr/include/c++/4.4/stdio.h:152: error: expected initializer before ‘fgetc’
/usr/include/c++/4.4/stdio.h:153: error: expected initializer before ‘fgetwc’
...
/usr/include/c++/4.4/stdio.h:363: error: ‘std::__getStream’ has not been declared
/usr/include/c++/4.4/stdio.h:364: error: ‘std::_fcloseall’ has not been declared
/usr/include/c++/4.4/stdio.h:365: error: ‘std::_fdopen’ has not been declared
/usr/include/c++/4.4/stdio.h:366: error: ‘std::_fgetc’ has not been declared
/usr/include/c++/4.4/stdio.h:367: error: ‘std::_fgetchar’ has not been declared
/usr/include/c++/4.4/stdio.h:368: error: ‘std::_fgetwc’ has not been declared
...
/usr/include/c++/4.4/math.h:152: error: expected initializer before ‘atan’
/usr/include/c++/4.4/math.h:153: error: expected initializer before ‘atan2’
/usr/include/c++/4.4/math.h:154: error: expected initializer before ‘ceil’
/usr/include/c++/4.4/math.h:155: error: expected initializer before ‘cos’
/usr/include/c++/4.4/math.h:156: error: expected initializer before ‘cosh’
...

Что же это такое…?

« Последнее редактирование: 13 Февраля 2011, 10:35:24 от tetramin »


Оффлайн
Mam(O)n

Обычно главная ошибка идёт первой в списке, остальное это лишь последствия.


Оффлайн
__v1tos

А как организовать вывод g++ в файл, что бы увидеть эти ошибки?
Я имею в виду перенаправить вывод в файл


Пользователь решил продолжить мысль 13 Февраля 2011, 11:01:35:


Нашел, попробуйте

g++ -o hiall hiall.cpp &> 1.txt

« Последнее редактирование: 13 Февраля 2011, 11:01:35 от __v1tos »

AMD Phenom II 945, GA-MA790GPT-UD3H (HD 3300), 5 GiB ram


Оффлайн
tetramin

И меня такая команда интересовала), спасибо.

Вот начало вывода компилятора:

Это в случае iostream


Оффлайн
__v1tos

Всетаки у вас что то не то установлено.
У меня например здесь файла           /usr/include/c++/4.4/stddef.h         нет
и             /usr/include/c++/4.4/_stddef.h:108: error: ‘__cdecl’ does not name a type
еще не видел ни в одном файле соглашения о вызовах __cdecl (в g++ такие вещи не нужны)

AMD Phenom II 945, GA-MA790GPT-UD3H (HD 3300), 5 GiB ram


Оффлайн
Mam(O)n

In file included from /usr/include/c++/4.4/stddef.h:25,

Интересно, как это у тебя заголовочный файл из простого «C» затисался в «C++» каталог? Мне кажется, что тебе придётся грохнуть этот каталог (/usr/include/c++/4.4) полностью и переустановить пакеты, которые подскажет команда dpkg -S /usr/include/c++/4.4


Оффлайн
tetramin

Снёс каталог /usr/include/c++/4.4
dpkg -S сказала, что нужно поставить libstdc+++-4.4. Поставил.
Попробовал скомпилировать. Ошибок значительно меньше стало. Теперь он просто говорил, что нет файла wchar.h
Я его скопировал из бэкапа папки 4.4 (которую как бы снёс).
Далее он начал ругаться на отсутствие locate.h
С ним я поступил так же, только скопировал его из папки /usr/include/bits
Ошибок стало больше… Решив, что проблема в каталоге /usr/include/bits и ещё, что такое копирование ни к чему хорошему не приведёт я просто написал

dpkg -S /usr/include/bits На что она мне ответила libc6-dev

Решилась проблема сносом и переустановкой libc6-dev и иже с ней.
Всем спасибо огромное!


  • Печать

Страницы: [1]   Вверх

Понравилась статья? Поделить с друзьями:
  • Error expected initializer before cin
  • Error expected initializer before char
  • Error expected indentation of 6 spaces but found 4 indent
  • Error expected identifier or before while
  • Error expected identifier or before token