|
Hi,
I have a project I downloaded from cp and dont know why, but when I try to use some classes that are in many (8 0r 9) files, I get this message:
*.cpp(2) : fatal error C1010: unexpected end of file while looking for precompiled header directive *.cpp
I get about 10 of these when I compile. Does anyone know what this means?
Where is a good place to look up compiler and linker errors?
I have had this problem with classes Ive wrote before.
Thanks.
|
|
|
|
|
The best place to lookup errors is in the help.
This means you are attempting to use precompiled headers, but the precompiled header is not present in the files. For Wizard generated files, this is "stdafx.h".
You can turn precompiled headers off for a project in the project settings. For large projects it will slow down the compiles significantly, for small projects, the impact is negligable, though measurable.
|
|
|
|
|
It's also possible to turn precompiled headers off for separates files so the project compilation won't slow down too much. Right click on the .cpp file, choose settings, go in the C/C++ tab, select Precompiled headers category and choose Not using precompiled headers
This is a better solution when you need to disable them only for a few files in a big project
|
|
|
|
|
Joe Woodbury have detailed it.
the same you can include"stdafx.h" to solve it .
dupengfei
|
|
|
|
|
Still confusing,
Goto Project->Settings->C/C++->Precompiled Headers
Select Automatic use of Precompiled Headers.
Thanks.
The Phantom.
|
|
|
|
|
Thanks. I fixed my problem. You say precompiled header files will speed up or slow down compile?
|
|
|
|
|
When the .PCH file is being created, the compile time will take longer. Subsequent compiles will be much shorter. If, however, you have a small project, the difference will not be noticeable.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Very easy, add
#include "stdafx.h"
to the files that give those errors.
Make sure it's the first #include though.
|
|
|
|
|
Hi, i have a question abt displaying doubles. Under _MBCS the following codes work but how do i display the double under Unicode? Thanks!
char *buffer;
int decimal, sign;
buffer = _ecvt( m_Height, 5, &decimal, &sign );
AfxMessageBox(buffer);
or
int decimal, sign;
AfxMessageBox(_ecvt(m_Height, 5, &decimal, &sign);
|
|
|
|
|
|
|
How about ansi.org?
Bernd
|
|
|
|
|
|
Only compiler designers and people with a strange liking for dull reading need it anyway.
Bernd
|
|
|
|
|
hi..
can someone tell me how do i get the IP address of my own PC???
tks a lot...
With Regards
Joseph R. Thomas
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
|
|
|
|
|
....
char host[80];
gethostname(host,80);
LPHOSTENT lpHost;
lpHost = gethostbyname(host);
UINT ip = ((LPIN_ADDR)lpHost->h_addr)->s_addr;
....
|
|
|
|
|
nope...doesnt work!!!
With Regards
Joseph R. Thomas
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
|
|
|
|
|
Try initializing winsock first:
#include "Winsock2.h"
#pragma comment(lib,"Ws2_32.lib")
int main(int argc, char* argv[])
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return -1;
}
char host[80];
gethostname(host,80);
LPHOSTENT lpHost;
lpHost = gethostbyname(host);
UINT ip = ((LPIN_ADDR)lpHost->h_addr)->s_addr;
char* addr= inet_ntoa(*(LPIN_ADDR)lpHost->h_addr);
return 0;
}
John
|
|
|
|
|
Ethernet adapter Local Area Connection:
Connection-specific DNS Suffix . :
Autoconfiguration IP Address. . . : 169.254.159.128
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . :
PPP adapter PacNet:
Connection-specific DNS Suffix . :
IP Address. . . . . . . . . . . . : 210.24.247.6
Subnet Mask . . . . . . . . . . . : 255.255.255.255
Default Gateway . . . . . . . . . : 210.24.247.6
the codes u gave me are fetching Autoconfiguration IP Address i.e 169.254.159.128
what i need is IP Address i.e 210.24.247.6
can someone please help???
With Regards
Joseph R. Thomas
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
|
|
|
|
|
Joseph_R_Thomas wrote:
can someone please help???
The problem is you have more than one ip address. The code above will return the first.
replace h_addr in the previous examples with h_addr_list[1] to get the second.
John
|
|
|
|
|
|
but what if the program keeps on shifting from one machine to another where some machine have more than one IP addresses and soem have only one????
With Regards
Joseph R. Thomas
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
|
|
|
|
|
It gets very complicated. Any network adapter may have multiple IP addresses. A computer may have more than one network adapters. I am not sure how you can figure out which ip address is the one that is connected to the internet and actually more than one can be connected to the internet.
You can use this code to go through the list of ip addresses:
#include "Winsock2.h"
#pragma comment(lib,"Ws2_32.lib")
int main(int argc, char* argv[])
{
WORD wVersionRequested;
WSADATA wsaData;
int err;
wVersionRequested = MAKEWORD( 2, 2 );
err = WSAStartup( wVersionRequested, &wsaData );
if ( err != 0 ) {
return -1;
}
char host[80];
gethostname(host,80);
LPHOSTENT lpHost;
lpHost = gethostbyname(host);
for(int i=0;(LPIN_ADDR)lpHost->h_addr_list[i] != 0;i++) {
UINT ip = ((LPIN_ADDR)lpHost->h_addr_list[i])->s_addr;
char* addr= inet_ntoa(*(LPIN_ADDR)lpHost->h_addr_list[i]);
}
return 0;
}
John
|
|
|
|
|
but then how to select the correct one????
With Regards
Joseph R. Thomas
Have a Super Blessed Day!
-------------------------
For God has not given us a spirit of fear, but of power and of love and of a sound mind.
2 Timothy 1:7
|
|
|
|
|
Joseph_R_Thomas wrote:
but then how to select the correct one????
They are all correct. I will explain. Think about the case where there is a lan connected to one network adapter and a second network adapter is conected to the internet using a dsl modem. One ip adddress will work to talk to the other pcs on the lan. The other ip address will work for the internet.
I assume you mean the one connected to the internet?? I am not sure.
John
|
|
|
|