I have problem with my program....it always say cc++/socket.h cannot be found. What is the difference between "socket.h" and "cc++/socket.h"?? and how can I define cc++/socket.h and how can I be sure that its included in the header files or libraries...thanks
What is the difference between "socket.h" and "cc++/socket.h"?? why ? does it work with just "socket.h" ? the difference is that the first one "socket.h" has to be in a directory searched by your linker wether it be a compiler include directory or your project directory. the second one indicates that the file should be in a sub directory of the search path, called cc++. first find the file on your system to make sure you have it, use search and then find out the path to the file and make sure that your compiler is looking at that directory. if you check your compiler options and find that it already searches the directory called cc++ then just use #include <socket.h> and dont worry about the cc++/
Thanks for the reply but why its still is not found since socket.h is alreday in the same directory as the source file??
okay... u have a few things mixed up there... both of u. when u include something and its in " ", such as #include "stdafx.h", it means that this file is in the same dirrectory as the project's root folder, having "cc++/Socket.h" means that if ur root folder is "c: \my wicked awsome project\", then socket.h is in the folder "c: \my wicked awsome project\cc++\". So if the path is wrong, fix that. if the inclde has < > around it, such as #include<iostream>, then it is in one of ur compilers include directory. This variers per compiler, and gernerally these are standard. if its #include<cc++/Socket.h>, then ur likely not going to be able to compile it because ur compiler didnt come with the library, unless u add it urself.
yes the use of "" and <> most likely does vary with compilers .. with mine Visual Studio "" simply means to START looking in the projects directory if not found then look along the registered paths. It does not exclude the paths its just to save time on compilation if the file is in the project dir the compiler looks there first and has no need to continue but you could wrap all your includes with quotations and not have a problem like #include "iostream" . I personally just use both forms for clarity so I know whether a header file is a standard header <> or one of my own "" . not really mixed up just maybe using a different compiler than you are
lol, i had to try it and yes the "" do work for iostream... but then again its nothing id try when im used to <>... :P anyways, back to the problem, either ur socket.h doesnt exist, or u put it in the wrong place
Wow guys I appreciate your concern to help me solve my problem on the issue of using "" or <> in header files. Yes! fortunately, I have fixed the problem now of locating my socket.h. So for recap, my problem is about locating my socket.h from #include<cc++/socket.h> line of command. After raeding your advises, I just used now #include<socket.h> and just add socket.h to the standard header files located in the default folder path of Microsoft Visual studio and it works now. But I have new problem now about the undefined classes. May I request you experts to please kindly explain to me what these error messages means? : ERROR MESSAGE WHILE COMPILING: Compiling... TCPCOB.CPP cprogram files\microsoft visual studio\vc98\include\socket.h(84) : error C2079: 'InetAddress' uses undefined class 'CCXX_CLASS_EXPORT' cprogram files\microsoft visual studio\vc98\include\socket.h(85) : error C2079: 'InetHostAddress' uses undefined class 'CCXX_CLASS_EXPORT' Thank you soo much guys! I really appreciate your help for me.
Ok..ok I have solved my problem with the undefined class CCXX_CLASS_EXPORT! I just defined it after the header files and used the command lines: #ifndef CCXX_CLASS_EXPORT #define CCXX_CLASS_EXPORT Now I have the remaining errors to complete my compilation. I am just confused though why SYNTAX ERROR? Did I do somethig wrong in the following lines? class InetAddress { private: // The validator given to an InetAddress object must not be a // transient object, but that must exist at least until the // last address object of its kind is deleted. This is an // artifact to be able to do specific checks for derived // classes inside constructors. const InetAddrValidator *validator; protected: struct in_addr * ipaddr; size_t addr_count; #if defined(WIN32) static MutexCounter counter; ---> THIS IS THE LINE WITH ERROR #else static Mutex mutex; #endif
well, i cant help u too well unless u tell me what the error message is. could be that what ur trying to decare does not exist, or there is a conflicing variable name, or many other things.
Still have same errors like the following: cprogram files\microsoft visual studio\vc98\include\socket.h(194) : error C2146: syntax error : missing ';' before identifier 'counter' cprogram files\microsoft visual studio\vc98\include\socket.h(194) : error C2501: 'counter' : missing storage-class or type specifiers class InetAddress { private: // The validator given to an InetAddress object must not be a // transient object, but that must exist at least until the // last address object of its kind is deleted. This is an // artifact to be able to do specific checks for derived // classes inside constructors. const InetAddrValidator *validator; protected: struct in_addr * ipaddr; size_t addr_count; #if defined(WIN32) static MutexCounter counter; --> ERROR according to compiler #else static Mutex mutex; #endif
okay... this one is simple, ur defining a variable of the type "size_t", which doesnt exist in ur code. ur error is coming from the fact that ur creating something that doesnt exist. size_t is a type to define sizes of strings and memory blocks, and is contained in the stddef.h header. so just add this at the beginning of ur code #include <stddef.h> that should get that line working damn internet exploere! and msn not using default browser... any other day, sohuld be posted with firefox
ohhh...I already added #include<stddef.h> in my header files but I still have the same 25 errors here even before I added the #include<stddef.h> as follows: Compiling... TCPCOB.CPP ..program files\microsoft visual studio\vc98\include\socket.h(194) : error C2146: syntax error : missing ';' before identifier 'counter' ..program files\microsoft visual studio\vc98\include\socket.h(194) : error C2501: 'counter' : missing storage-class or type specifiers ..program files\microsoft visual studio\vc98\include\socket.h(762) : error C2146: syntax error : missing ';' before identifier 'readLine' ..program files\microsoft visual studio\vc98\include\socket.h(762) : error C2501: 'ssize_t' : missing storage-class or type specifiers ..program files\microsoft visual studio\vc98\include\socket.h(762) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(915) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(1251) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(1292) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(1423) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(1476) : error C2146: syntax error : missing ';' before identifier 'timeout' ..program files\microsoft visual studio\vc98\include\socket.h(1476) : error C2501: 'timeout_t' : missing storage-class or type specifiers ..program files\microsoft visual studio\vc98\include\socket.h(1476) : error C2501: 'timeout' : missing storage-class or type specifiers ..program files\microsoft visual studio\vc98\include\socket.h(1558) : error C2629: unexpected 'class TCPStream (' ..program files\microsoft visual studio\vc98\include\socket.h(1558) : error C2238: unexpected token(s) preceding ';' ..program files\microsoft visual studio\vc98\include\socket.h(1570) : error C2629: unexpected 'class TCPStream (' ..program files\microsoft visual studio\vc98\include\socket.h(1570) : error C2238: unexpected token(s) preceding ';' ..program files\microsoft visual studio\vc98\include\socket.h(1577) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(1610) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(1699) : error C2504: 'Thread' : base class undefined ..program files\microsoft visual studio\vc98\include\socket.h(1715) : error C2061: syntax error : identifier 'timeout_t' ..program files\microsoft visual studio\vc98\include\socket.h(1723) : error C2146: syntax error : missing ';' before identifier 'initial' ..program files\microsoft visual studio\vc98\include\socket.h(1730) : error C2146: syntax error : missing ';' before identifier 'final' ..program files\microsoft visual studio\vc98\include\socket.h(1730) : error C2535: 'int __thiscall TCPSession::CCXX_MEMBER(void)' : member function already defined or declared ..program files\microsoft visual studio\vc98\include\socket.h(1723) : see declaration of 'CCXX_MEMBER' ..program files\microsoft visual studio\vc98\include\socket.h(1731) : warning C4183: 'final': member function definition looks like a ctor, but name does not match enclosing class ..program files\microsoft visual studio\vc98\include\socket.h(1761) : error C2143: syntax error : missing ';' before '<<' ..program files\microsoft visual studio\vc98\include\socket.h(1761) : fatal error C1004: unexpected end of file found Error executing cl.exe. TCPCOB.exe - 25 error(s), 1 warning(s) Do you think I forgot to add some more header files?
And I have observed, its pointing to socket.h again?? . Do you think I still have some errors in the socket.h?
class InetAddress { private: // The validator given to an InetAddress object must not be a // transient object, but that must exist at least until the // last address object of its kind is deleted. This is an // artifact to be able to do specific checks for derived // classes inside constructors. const InetAddrValidator *validator; protected: struct in_addr * ipaddr; size_t addr_count; #if defined(WIN32) static MutexCounter counter; ----------> 1st and 2nd lines of errors #else static Mutex mutex; #endif Deleting intermediate files and output files for project 'ClientStream - Win32 Debug'. --------------------Configuration: ClientStream - Win32 Debug-------------------- Compiling... TCPCOB.CPP c\program files\microsoft visual studio\vc98\include\socket.h(194) : error C2146: syntax error : missing ';' before identifier 'counter' c\program files\microsoft visual studio\vc98\include\socket.h(194) : error C2501: 'counter' : missing storage-class or type specifiers ssize_t readLine(char *buf, size_t len, timeout_t timeout = 0); --------> 3rd error message or the one below: cprogram files\microsoft visual studio\vc98\include\socket.h(762) : error C2501: 'ssize_t' : missing storage-class or type specifiers
Oh ok meyup , I already solved my problem with the #inlclude <stddef.h>. Thank you soo much. You are right! I just missed that header file. Then the reason why I still have those 25 errors before is that I have two socket.h used. I have figured it out now. Now after being sure that I already fixed the previous problems, I recompiled it again and had 3 errors left: Compiling... TCPCOB.CPP c\linux\tcpcob.cpp(86) : error C2065: 'start' : undeclared identifier c\linux\tcpcob.cpp(120) : error C2259: 'ThreadSrc' : cannot instantiate abstract class due to following members: c\linux\tcpcob.cpp(75) : see declaration of 'ThreadSrc' c\linux\tcpcob.cpp(120) : warning C4259: 'void __thiscall ost::Thread::Run(void)' : pure virtual function was not defined c\linux\thread.h(1066) : see declaration of 'Run' c\linux\tcpcob.cpp(120) : error C2259: 'ThreadSrc' : cannot instantiate abstract class due to following members: c\linux\tcpcob.cpp(75) : see declaration of 'ThreadSrc' c\linux\tcpcob.cpp(120) : warning C4259: 'void __thiscall ost::Thread::Run(void)' : pure virtual function was not defined c\linux\thread.h(1066) : see declaration of 'Run' Error executing cl.exe. TCPCOB.exe - 3 error(s), 2 warning(s) From the class below: class ThreadSrc: public Thread { private: unsigned char iCh; ClientStream *ArrTCPSesn[100]; int n; public: ThreadSrc() { n = 0; start(); -------> where the 1st line error occured } void run() { ClientStream tcp("127.0.0.1",1024); while(true) { iCh = tcp.ReceiveData(); cout << iCh; for(int clnt = 0; clnt < n; clnt++) { ArrTCPSesn[clnt]->SendCh(iCh); } } tcp.close(); } void AddClient(ClientStream * tcp) { ArrTCPSesn[n] = tcp;//add client to vector n++; } }; 2nd Error:: int main(int argc, char *argv[]) { ThreadSrc thread;------> 2nd error message ClientStream *tcp; BroadcastAddress addr; 3rd Error: : class ThreadSrc: public Thread -----> 3rd Error Message { private: unsigned char iCh; ClientStream *ArrTCPSesn[100]; int n;