error messages

Well I finally got the Header file in the compiler and was able to get it to see it but I got this error message when doing the Hello world lesson to test it out.

#include"../../std_lib_facilities.h"

int main ();

{ <-----//ERROR:expected a declaration


cout<<"Hello,World.\n";

return 0
}



when I ran it anyway a full page of errors for the std_lib_facilities.h file came up....I know im a pain in the rear but im not a quitter! I went back to Bajarne Stroustrup's site and he had updated his suggested compiler from the 2005 edition (which doesn't exist on the site any more) to the 2010 edition and that's the one I got do you think the std_lib_file won't work with the new edition?
Last edited on
Remove the semicolon from behind int main()
removing the semicolon from the main function, it moved the error to the closing bracket so I added one after return 0 and that fixed those errors, (Thank you )but this is what comes up when I run it. See the problem?

1>------ Build started: Project: hello world, Configuration: Debug Win32 ------
1> hello world.cpp
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(71): error C2868: 'std::vector<_Ty,_Ax>::size_type' : illegal syntax for using-declaration; expected qualified-name
1> c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(95) : see reference to class template instantiation 'Vector<T>' being compiled
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(71): error C2143: syntax error : missing ';' before '='
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(71): error C2238: unexpected token(s) preceding ';'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(80): error C2061: syntax error : identifier 'initializer_list'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(80): error C2535: 'Vector<T>::Vector(void)' : member function already defined or declared
1> c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(75) : see declaration of 'Vector<T>::Vector'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(102): error C2868: 'std::basic_string<_Elem,_Traits,_Ax>::size_type' : illegal syntax for using-declaration; expected qualified-name
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>,
1> _Ax=std::allocator<char>
1> ]
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(102): error C2143: syntax error : missing ';' before '='
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(102): error C2238: unexpected token(s) preceding ';'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(213): error C2143: syntax error : missing ';' before '{'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(213): error C2275: 'std::tr1::uniform_int_distribution<>' : illegal use of this type as an expression
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(213): error C2143: syntax error : missing ';' before '}'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(222): error C2988: unrecognizable template declaration/definition
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(222): error C2059: syntax error : 'using'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(243): error C2143: syntax error : missing ';' before '<'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(243): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(243): error C2988: unrecognizable template declaration/definition
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(243): error C2059: syntax error : '<'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(251): error C2143: syntax error : missing ';' before '{'
1>c:\users\diana\documents\visual studio 2010\projects\std_lib_facilities.h(251): error C2447: '{' : missing function header (old-style formal list?)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on
One thing which caught my eye is, there should be space between #include and the file name.
Can you please tell what does this library std_lib_facilities.h do? I have not used this library before. Looks like there are so many things in the header file which is not compiling, I would doubt if it is compatible , I will try using 2011 or 2013 visual studio just to be make sure it is fully compatible. Good luck.
#include <iostream>
using namespace std;

int main () {

cout <<"Hello World!\n"; (cout << "Hello World!" << endl;)

return 0;
}

There do you have the easy code of "Hello World!"
Np ;)

The thing that maked the error was that you fogot the ; in "return 0;"

In Code::Block
Last edited on
Thank you for your suggestions,

I have been trying to get this file in my compiler program for over a month, with tons of help from here, Finally got it to work.

The tutorial for including this file said no spaces. I was finally able to get it there and for it to be recognized, you can't have any spaces for it to work.

removing the semicolon from the main function and adding it to the end of the return 0 solved those issue. I just wanted to know if there was a problem with the std_lib_facilities.h file, if code could become outdated and if by reading the above error messages you could tell if it was that code or something else im doing wrong.
Could you please tell me what std_lib_facilities.h is?
Sure, there a collection of Header files that a teacher wrote to accompany his book, Programming, Principles and Practices using C++....by Bjarne Stroustrup.
I need these files to do the lessons in the book.
I don't know which version of that header you are using. i googled for the filename, the first version i found was 234 lines long. It gave many unpleasant-looking errors when i tried to compile with it.

Then i tried the version at the following link;
http://www.stroustrup.com/Programming/PPP2code/std_lib_facilities.h

That's even longer, 255 lines. but i did manage to compile this "hello world" with it:
1
2
3
4
5
6
7
8
#include <std_lib_facilities.h>

int main ()
{ 
    cout<<"Hello,World.\n";
    
    return 0;
}


However, it looks as though the header does different things depending on which compiler is used, so it may still be unreliable.
Last edited on
Chervil, this is interesting. That was the file I was using ( I reloaded the above file from your link) im looking at your example the thing I see is your include line. The tutorial said to put the file in one of three places in the compiler program to get the compiler to see and use it: #include../../../"std_lib_facilities.h" the file shows up in a drop down menu as described in the tutorial. I tried it the way your example showed and it just doesn't want to see the file. Where exactly did you put the header file and how, to be able to use the include im seeing in your example?
Last edited on
Don't worry about my include line. I customised my IDE to search some user-specified location for header files. That allows me to put headers for global use in that directory.

Your own #include must have been perfectly ok, or the compiler would have halted with a "file not found" message.

However - I tried a different compiler and could not get it to work at all.
The one which worked for me was MinGW GCC 4.8.1 32-bit compiler.

If that's not the one you use, you may want to try code::blocks
http://www.codeblocks.org/

or possibly Orwell Dev-C++ Version 5.6.3
http://orwelldevcpp.blogspot.com/
Topic archived. No new replies allowed.