Fehler? Winsock
-
Hallo
Kann mir jemand bei dieser Fehlermeldung helfen. Das Programm ist ein Beispiel aus der MSDN, leider klappt etwas nicht mit den Headerfiles. Nur was? Aus der Hilfe für die Fehlermeldung bin ich nicht schlauer geworden.
unexpected end of file while looking for precompiled header directive
Error executing cl.exe.#include <windows.h> #include <winsock.h> #define PORTNUM 5000 // Port number #define HOSTNAME "DRS05115" // Server name string // This should be changed // according to the server. int WINAPI WinMain ( HINSTANCE hInstance, // Handle to the current instance HINSTANCE hPrevInstance,// Handle to the previous instance LPTSTR lpCmdLine, // Pointer to the command line int nCmdShow) // Show state of the window { int index = 0, // Integer index iReturn; // Return value of recv function char szClientA[100]; // ASCII string TCHAR szClientW[100]; // Unicode string TCHAR szError[100]; // Error message string SOCKET ServerSock = INVALID_SOCKET; // Socket bound to the server SOCKADDR_IN destination_sin; // Server socket address PHOSTENT phostent = NULL; // Points to the HOSTENT structure // of the server WSADATA WSAData; // Contains details of the // Winsocket implementation // Initialize Winsocket. if (WSAStartup (MAKEWORD(1,1), &WSAData) != 0) { wsprintf (szError, TEXT("WSAStartup failed. Error: %d"), WSAGetLastError ()); MessageBox (NULL, szError, TEXT("Error"), MB_OK); return FALSE; } // Create a TCP/IP socket that is bound to the server. if ((ServerSock = socket (AF_INET, SOCK_STREAM, 0)) == INVALID_SOCKET) { wsprintf (szError, TEXT("Allocating socket failed. Error: %d"), WSAGetLastError ()); MessageBox (NULL, szError, TEXT("Error"), MB_OK); return FALSE; } } /* hier het es dann noch weiter*/
-
Und ist das MFC ??
-
falls du mit msvcc kompilierst, da muss man glaub ich die winsock lib mitlinken
-
Der Fehler hat m. E. nichts mit dem Linker zu tun!
Ich nehme an, Du erstellst das Programm mit MSVC?!?! Dann geh in dem betreffenden Projekt auf "Settings" [ALT+F7], gehe dort zur Registerkarte C/C++ und wähle in der Kategorie "Precompiled Headers" den Radioknopf "Not using pch" oder "Automatic use of pch".Hoffe, das hilft.
-
Danke, das mit der Registerkarte hat gestimmt. Dafür habe ich jetzt andere Fehler, das war wohl ein blödes Beispiel aus der MSDN.