|
The reason I ask is because I tried that, and the project came with some headers and I removed them all and created the typical first program
#Include <iostream.h>
void main
{
cout << "Hello, world";
}
And It wouldn't compile citing "Error 1 fatal error C1010: unexpected end of file while looking for precompiled header. Did you forget to add '#include "stdafx.h"' to your source? c:\documents and settings\elaintabi\my documents\visual studio 2008\projects\helloworld\helloworld\helloworld.cpp 7 helloWorld"
because I removed stdafx.h and the include, why do I need this file if in my book it doesn't include it in its sample?
|
|
|
|
|
this is because you might have started a project from a template or something.
just deactivate the precompiled headers in the compiler settings to have this error disappeard.
BTW, be careful. #include is with a small i , not #Include .
Moreover, you should prefer using iostream (without .h) header.
also, you code won't work for some other reasons.
cout won't be found in the global namespace. just prepend it with std:: .
and main is a function, so you have to give it a pair or parenthesis:
#include <iostream>
void main() {
std::cout << "Hello World !";
}
|
|
|
|
|
Got it, thanks, I had to use #include "iostream" and fully qualify cout using std::cout, which is slightly annoying but it work sso i feel better about it hahah
|
|
|
|
|
EliottA wrote: fully qualify cout using std::cout, which is slightly annoying
well beginners often fell std:: namespace annoying, but when going further in the experience, you kinda love it
In fact, you could declare a using namespace std; befoire the main() call and use only cout , but it's prefered to have the namespace prepended (and "std " is not what i'd call a loooooong name )
|
|
|
|
|
Book didn't specify that, but google did. TY for the help, 5's all around.
|
|
|
|
|
Also did you get the precomplied header error?That's a technique VC++ applies to keep people away from it. LOL! it gives that stupid pch error on compilation and discourages people. Dont get deceived by it.. . Also when you choose the project type next time, you may select "Add common headers-MFC" radio that you will find on the right side when are going through the project wizard. That sets up namespace for stl & required headers for MFC, in case you'd want to test MFC classes too.
Good luck
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
right now, I'm just trying to code a dog.
|
|
|
|
|
EliottA wrote: right now, I'm just trying to code a dog.
Then I'd suggest VB. You dont need to code. It's already there. it's just that.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus
Best wishes to Rexx[^]
|
|
|
|
|
Hello
Can anyone help. I am working an a quite large program and seemed to have lost the ability to jump to functions within a couple of my classes from the tool bar. It looks like the classes have dropped out of class view.
therefore I can not use any of the tools or wizards with these classes.
Any help in restoring the normal operation of visual studio would be appreciated.
Desmond Mardle
BSc MIEEE
RF/ATE ENGINEER
|
|
|
|
|
I'm note sure, but in such cases, deleting .ncb file and other temp files from project folder does the trick.
|
|
|
|
|
I have tried deleting all files in the project folder not generated by me which made no difference.
thanks anyway
Desmomd Mardle
|
|
|
|
|
Try removing the files containing the broken classes from the project and then add them again. This usually fixed the problem in VS6 when it messed up. Never had the problem in VS2008 though.
|
|
|
|
|
Good Morning Niklas
I tried deleting and re-adding the files but it made no difference.
Thanks for the suggestion.
I also used to be able to fix this type of problem in VS6. But seems to be difficault to fix in VS2008. Theres probley a simple answer out there somewhere.
Desmond Mardle
|
|
|
|
|
Hello folks!
Do you happen to know any method of dumping the call stack to the output window of VS or maybe to a log file during runtime (only in a debug run with debugger present of course)? I mean, somethging like, placing a __DUMP_CALL_STACK_HERE__ macro in a method of a class dumping the callstack whenever it is called or such? It would be very useful sometimes, i doubt it is possible, but i thought i ask the more experienced people. (Ah, and another thing, we are using VS2003 (v7.1))
Thanks in advance,
Code-o-mat
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
This message[^] will point you to a resource that'll help you get the call stack. You can then dump that as you want.
Alternatively, I'm pretty sure this CP article[^] has stack trace code in it as well.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks, i'll check these out.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Hi,
In my project, I have an .cpp file which contains a set of utility functions like TrimMyString() etc which could be called a lot of times.
I have made these functions global and included the .cpp file in places where I call these utility functions.
When I call these global methods from another function in my user defined class (say I want to trim a character array in one of my user defined class functions), I am getting a linking error
"fatal error LNK1169: one or more multiple defined symobls found".
However, when I make them global and static by including the static keyword, then this error no longer exists and every thing works perfectly.
How do i make this a non-static global function because this is what the current requirment is?
Thanks.
|
|
|
|
|
Comp_Users wrote: I have an .cpp file which contains a set of utility functions like TrimMyString() etc which could be called a lot of times.
I assume you have declared its prototypes in a header file, and are using it wherever that function in needed , isn't it ?
|
|
|
|
|
No. I am not.
I just have the global function body in the .cpp file and including this file in places where I am calling it.
|
|
|
|
|
Comp_Users wrote: I just have the global function body in the .cpp file and including this file in places where I am calling it.
You should not include cpp file in other files. Do , what I said in my first post.
|
|
|
|
|
Tried what you asked me to do.
Created a new .h file and added the function declarations in the global space in the .h file and in the utility .cpp file, included this newly created .h file.
Now in the .cpp file where i am calling these utility functions, I have included the newly added .h file. But the error still persists.
These are the exact error messages.
1>XMLLoader.obj : error LNK2005: "void __cdecl TrimString(wchar_t *)" (?TrimString@@YAXPA_W@Z) already defined in UtilityFunctions.obj
1>Output/Sample.dll : fatal error LNK1169: one or more multiply defined symbols found
|
|
|
|
|
Did you put include guards[^] in your header file ? Otherwise it will be included multiple times.
|
|
|
|
|
Comp_Users wrote: I just have the global function body in the .cpp file and including this file in places where I am calling it.
You really need a good C tutorial.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Could you please tell me as to what is causing this to happen?
Is it the way I am calling an global function?
Pls help.
|
|
|
|
|
Comp_Users wrote: Could you please tell me as to what is causing this to happen?
The linker is telling you exactly what the problem is.
You need to put the function declarations in a .h file like:
#if !defined(ABC123)
#define ABC123
#pragma once
int TrimMyString();
int PaintMyHouse();
int SellMyStock();
#endif You need to put the function definitions in a .cpp file. Make sure both files are added to the project. Then in any file that will be using those functions, simply #include the .h file near the top.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|