I brought all the correct files over into a new project, and it did not compile. It said:
c:\documents and settings\alex apostol\my documents\c and c++\print\calculator\divider.cpp(53) : fatal error C1010: unexpected end of file while looking for precompiled header directive
main.cpp
The bold part is the important part, the compiler already knows where my files are. I do not understand what they mean. I am very sorry for bugging the dev forum lately, but I am just having a hard time learning C/C++ (mostly due to compiler problems).
Hi Alex, don't worry about posting to learn. That's one of the reasons the forum is here. ( Always good to do a search first of course just in case it's been covered )
The only time I've seen 'unexpected end' messages is in circumstances where something is incomplete like a missing curly bracket } so I would suggest matching up pairs of brackets as you may have lost one in a cut & paste somewhere. You could also try adding one } just for fun at the end of the source to see if the message changes
Go into Project->Settings... and for each source file with that error, go into the C / C++ tab, Precompiled Headers category, and select Not using precompiled headers.
Dan East
Thank you both very much. I have fixed it by disabling the precompiled headers, just like Mr. East said.
Dan, I'm just curious, as I've of course like everyone gotten the unexpected end of file error plenty of times because I didn't close a code block... why does the precompiled headers option cause this problem though?
The purpose of precompiled headers is to reduce the compile time for sources that include very complex headers. Specifically, source files that need to include windows.h. When precompiled headers are enabled for a specific source file, the compiler will search for an #include matching the specified precompiled header. At the point it's found the compiler inserts the specialized "#include" using the already compiled header. If it is not found you get the error seen above. Basically in the settings you are telling it to use a certain precompiled header, so you must include that header in the source.
Another very weird part of precompiled headers that gave me fits years ago is that the compiler ignores preprocessor directives (#if, etc) when it searches for the #include with precompiled header specified for that source file.
Basically you can / should use precompiled headers for sources that need windows.h (or stdafx.h for MFC builds). Otherwise disable it for source files that don't need it.
Dan East