Compiler Issue or human error?

Dave Williss dwilliss@microimages.com
Thu Apr 12 22:27:00 GMT 2007


Are you using gcc or g++?  gcc won't parse C++, so it doesn't know what 
"class" is.

John Love-Jensen already pointed out your sizeof() problem.  I 
personally would never memset a class to 0 in the ctor unless you're 
very sure that you're never going to add members which will have their 
own constructors.  It's just asking for trouble down the road.  It's 
better to write the constructor as:

 CThreadContext::CThreadContext (
      ) :
     m_hThread(0),
     m_dwTID(0),
     m_pUserData(0),
     m_pParent(0),
     m_dwExitCode(0)
     { }

Kalinowski, Jeremy wrote:
> Hey all,
> The reason I'm writing is because I created this very simple class and its
> not compiling. Now I know many people do this and are like why won't this
> compile, but I wanted to know if this is a compiler issue or just my human
> error. The errors I get are as follows:
> error: syntax error before "CThreadContext"
> CThreadContext.h:5: error: syntax error before '{' token
> CThreadContext.h:18: error: syntax error before '}' token
> Honestly I don't see what is going on and I'm worried I'm just not seeing
> something. Give me your thoughts. Also this is a header file. Thanks.
> #include <windows.h>
> #include <winbase.h>
>
> class CThreadContext{
>
> 	public:
> 	CThreadContext(){
> 		memset(this,0,sizeof(this));
> 	}
> 	
> 	HANDLE m_hThread;
> 	DWORD m_dwTID;
> 	LPVOID m_pUserData;
> 	LPVOID m_pParent;
> 	DWORD m_dwExitCode;
> 	
> };
>
>
>
>
> The information contained in this message is confidential and intended only
> for use of the designated recipient(s) named above.  If the reader of this
> message is not the intended recipient or an agent responsible for delivering
> it to the intended recipient, you are hereby notified that you have received
> this message in error, and that any review, dissemination, distribution,
> copying, or alteration of this message is strictly prohibited.  If you have
> received this communication in error, please notify the originator
> immediately and remove it from your system.
>
>
>   



More information about the Gcc-help mailing list