what went wrong?

Started by
7 comments, last by erissian 17 years, 3 months ago
I am implementing a network for a sample program. Once if I included "stdafx.h" to the sample program, there would be a lot of errors/warnings coming out. The followings are a few examples of the errors. warning C4005: '_ftcscat' : macro redefinition warning C4995: 'lstrcpyW' : name was marked as #pragma deprecated error CS2011 : 'sockaddr' : 'struct' type redefinition I think it may be because of the "dxstdafx.h" included in the sample program already. There may be some repetitions. So I tried not including "stdafx.h", however, in the sample program, there is: "#ifndef __AFXWIN_H__ #error include 'stdafx.h' before including this file for PCH #endif". The program cannot find the defination of __AFXWIN_H__, and another error of "include 'stdafx.h' before including this file for PCH" appears. I was trying to find the definition of __AFXWIN_H__ in the "stdafx.h" and include it in "dxstdafx.h", however, I couldn't find a single related code. Could someone help me, please? Thanks a lot!
Advertisement
Can you post us the content of both files (enclosed in [source lang="cpp"][/source] tags)?

For me it seems that either one is necessary, not both. However, maybe the purpose of dxstdafx.h is to be included in stdafx.h. I haven't played with the DX samples lately, so I can't be sure.

Regards,
It's been ages since I did work in Windows, but I remember that stdafx.h is a standard name for PCH. The contents vary from project to project. Sometimes projects expect you to include certain headers, but are finicky about the order you list them in.

There shouldn't be anything special about dxstdafx.h. I'm sure it just shows you what's needed in stdafx.h to make DirectX more convenient. Try including stdafx.h before dxstdafx.h.

How was the project configured before you made changes?
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Quote:Original post by erissian
It's been ages since I did work in Windows, but I remember that stdafx.h is a standard name for PCH. The contents vary from project to project. Sometimes projects expect you to include certain headers, but are finicky about the order you list them in.

There shouldn't be anything special about dxstdafx.h. I'm sure it just shows you what's needed in stdafx.h to make DirectX more convenient. Try including stdafx.h before dxstdafx.h.

How was the project configured before you made changes?


I tried including "stdafx.h" in front of the "dxstdafx.h", the previous errors and warnings are gone. :)
But the error "include 'stdafx.h' before including this file for PCH" is still there, because of the followind code.
"#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif".

can I just comment all these stuff?
Quote:Original post by Emmanuel Deloget
Can you post us the content of both files (enclosed in [source lang="cpp"][/source] tags)?

For me it seems that either one is necessary, not both. However, maybe the purpose of dxstdafx.h is to be included in stdafx.h. I haven't played with the DX samples lately, so I can't be sure.

Regards,


What do you mean by "(enclosed in ...)"?

sorry, I coudn't understand. But in "stdafx.h", there are only a few lines:
"
#define VC_EXTRALEAN

#include <afxwin.h> // MFC core and standard components
#include <afxext.h> // MFC extensions
#include <afxsock.h> // MFC socket extensions
"

However, in "dxstdafx.h", there are lots of stuff, but dun have the above lines.

Both "stdafx.cpp" and "dxstdafx.cpp" are just including "stdafx.h" and "dxstdafx.cpp" respectively.

[Edited by - Aileen on January 19, 2007 7:34:07 AM]
Quote:Original post by Aileen
But the error "include 'stdafx.h' before including this file for PCH" is still there, because of the followind code.
"#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif".

can I just comment all these stuff?


You could, but it would be better to change stdafx.h in this manner:

#ifndef __AFXWIN_H__#define __AFXWIN_H__// All the stuff that was there originally#endif
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)
Quote:Original post by erissian
Quote:Original post by Aileen
But the error "include 'stdafx.h' before including this file for PCH" is still there, because of the followind code.
"#ifndef __AFXWIN_H__
#error include 'stdafx.h' before including this file for PCH
#endif".

can I just comment all these stuff?


You could, but it would be better to change stdafx.h in this manner:

*** Source Snippet Removed ***


I copied the content in "stdafx.h" into "dxstdafx.h", so that I can only include "dxstdafx.h" instead of including both. Then most of the errors are gone.

But because I am adding network into original project, I need to add one more resource file. After I added the "chatter.rc" to the resource file in solution explorer, I compiled and got the following error:

" fatal error CVT1100: duplicate resource. type:ICON, name:1, language:0x0409

fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt"

I searched from the web, it says that the VC++ cannot compile two resource files. What can I do? Does it help if I combine the two resource files?
I'm not sure, but when I look at the error:

fatal error CVT1100: duplicate resource. type:ICON, name:1, language:0x0409

it suggests that two icons in the project have been given the same identifier (name:1). What do the numeric values of the icons' identifiers resolve to?

Either way, if VC can't compile two resource files then of course combining them should solve the problem. You should be able to include one of them in the other with #include since rc scripts are fed through a C/C++ preprocessor before the resource compiler sees them.
Again, it's been a while, but it used to be that you could simply concatenate two resource files, so long as all of the IDs are unique. As EasilyConfused pointed out, and as your error implies, ID collision is your problem now,
We''re sorry, but you don''t have the clearance to read this post. Please exit your browser at this time. (Code 23)

This topic is closed to new replies.

Advertisement