Declaration of CSemaphore fails
-
Good Morning Everyone, I am using Visual C++ 6.0 MFC. I am writing my first multi-threaded application and I need to be able to use semaphores. In examples that I have looked at they say to declare the semaphore class as CSemaphore cph(1, 2) for example. When I try to declare the semaphore in my class header file the compiler returns with the type of error that you would get if you did not #include a needed header file. Is there a header file that CSemaphore requires to be #included? Thanks, Buck:confused:
-
Good Morning Everyone, I am using Visual C++ 6.0 MFC. I am writing my first multi-threaded application and I need to be able to use semaphores. In examples that I have looked at they say to declare the semaphore class as CSemaphore cph(1, 2) for example. When I try to declare the semaphore in my class header file the compiler returns with the type of error that you would get if you did not #include a needed header file. Is there a header file that CSemaphore requires to be #included? Thanks, Buck:confused:
-
BuckBrown wrote:
Is there a header file that CSemaphore requires to be #included?
They hide that information in the documentation[^]
led mike
I guess I really don't understand. I read this documentation earlier and thought the idea was something like this - class CTests : public CWnd { // Construction public: CTests(); CTemperature* pTemperature; COutput* pOutput; CGPIB* pGPIB; CTabPageSSL* pTabPage; CSemaphore cph(1, 5); // Attributes private: If I remark out the declaration it compiles fine, if not it does not compile. Buck
-
I guess I really don't understand. I read this documentation earlier and thought the idea was something like this - class CTests : public CWnd { // Construction public: CTests(); CTemperature* pTemperature; COutput* pOutput; CGPIB* pGPIB; CTabPageSSL* pTabPage; CSemaphore cph(1, 5); // Attributes private: If I remark out the declaration it compiles fine, if not it does not compile. Buck
-
I guess I really don't understand. I read this documentation earlier and thought the idea was something like this - class CTests : public CWnd { // Construction public: CTests(); CTemperature* pTemperature; COutput* pOutput; CGPIB* pGPIB; CTabPageSSL* pTabPage; CSemaphore cph(1, 5); // Attributes private: If I remark out the declaration it compiles fine, if not it does not compile. Buck
BuckBrown wrote:
class CTests : public CWnd { // Construction public: CTests(); CTemperature* pTemperature; COutput* pOutput; CGPIB* pGPIB; CTabPageSSL* pTabPage; CSemaphore cph(1, 5);
Doing that in the header file won't compile. The overloaded constructor should be invoked using the constructor of your CTests class:
CTests::CTests() : cph(1, 5) { // do whatever else you want to in the constructor here }
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac
-
BuckBrown wrote:
I read this documentation earlier
maybe your definition of "reading" is different than mine. From the documentation:
Requirements
Header: afxmt.h
led mike
-
BuckBrown wrote:
class CTests : public CWnd { // Construction public: CTests(); CTemperature* pTemperature; COutput* pOutput; CGPIB* pGPIB; CTabPageSSL* pTabPage; CSemaphore cph(1, 5);
Doing that in the header file won't compile. The overloaded constructor should be invoked using the constructor of your CTests class:
CTests::CTests() : cph(1, 5) { // do whatever else you want to in the constructor here }
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week Zac