Can't compile

Hi Experts,
I'm again trying to compile an old piece of code I did in Visual C++ 6.0 - now in Visual C++ 2008 Pro.  I have the following additional include folders:
C:\WinDDK\7600.16385.0\inc\api;C:\WinDDK\7600.16385.0\inc\ddk;C:\WinDDK\7600.16385.0\inc\crt;C:\WinDDK\7600.16385.0\inc\atl71;c:\WinDDK\7600.16385.0\bin\x86\OACR

I'm getting these errors - any ideas?
Thanks!

>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(736) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(737) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(737) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(738) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(739) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(739) : error C2143: syntax error : missing ')' before ';'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(773) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(774) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(774) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(947) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(948) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(948) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1003) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1004) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1004) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1139) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1139) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1139) : error C2143: syntax error : missing ')' before ';'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1504) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1504) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(1504) : error C2143: syntax error : missing ')' before ';'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(841) : error C2061: syntax error : identifier '_In_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(841) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(841) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(858) : error C2061: syntax error : identifier '_Out_opt_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(859) : error C2061: syntax error : identifier '_Out_opt_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(901) : error C2061: syntax error : identifier '_In_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(902) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(902) : error C2143: syntax error : missing ')' before ';'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(903) : error C2061: syntax error : identifier '_In_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(904) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(904) : error C2143: syntax error : missing ')' before ';'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(904) : error C2535: 'int CDC::Escape(void)' : member function already defined or declared
1>        c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(901) : see declaration of 'CDC::Escape'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(1165) : error C2061: syntax error : identifier '_In_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(1166) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(1166) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdd_.h(39) : error C2065: '_Inout_' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdd_.h(39) : error C2146: syntax error : missing ')' before identifier 'CDataExchange'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdd_.h(39) : warning C4229: anachronism used : modifiers on data are ignored
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdd_.h(39) : error C2182: 'DDX_Text' : illegal use of type 'void'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdd_.h(39) : error C2365: 'DDX_Text' : redefinition; previous definition was 'function'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxdd_.h(39) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(2238) : error C2061: syntax error : identifier '_Out_z_cap_post_count_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(2238) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(2238) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(2389) : error C2061: syntax error : identifier '_Inout_z_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(2391) : error C2061: syntax error : identifier '_Inout_z_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afxwin.h(2394) : error C2061: syntax error : identifier '_Out_z_cap_c_'
1>c:\program files\microsoft visual s
LVL 1
threadyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AnilKumarSharmaCommented:
0
ZoppoCommented:
Hi thready,

I just took a look where '_Out_z_cap_' is declared and how it is included:

- declared in 'sal.h'
- 'sal.h' is included in 'new.h' if these two preprocessor defines doesn't exist: _INC_NEW, _MSC_EXTENSIONS
- 'new.h' is included in 'afx.h' if this preprocessor define doesn't exist: _INC_NEW

So, IMO the only reason at least the first error could be that either _INC_NEW or _MSC_EXTENSIONS is defined before 'afx.h' (or 'afxwin.h') is included. Please check if '#include <afxwin.h>' is the first include in your 'stdafx.h' and if one of the two mentioned defines are declared in the project's compile settings.

Hope that helps,

ZOPPO
0
js-profiCommented:
i currently have afx.h from vs2003 only. could you double-click on the first error and post some snippet of code around the first error - say 20 lines before and 10 after. also check the path of the afx.h (put the mouse cursor above the editor tab until path was shown) that it is of correct version vs2008.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

threadyAuthor Commented:
Hi Zoppo,
<afxwin.h> is the first item included in stdafx.h.  How do I check that _INC_NEW is defined?
0
ZoppoCommented:
Hm - you could either check the compiler settings or add this code befor the #include <afxwin.h> in your stdafx.h:

> #ifdef _INC_NEW
> #error _INC_NEW already defined
> #endif
> #ifdef _MSC_EXTENSIONS
> #error _MSC_EXTENSIONS already defined
> #endif

ZOPPO
0
threadyAuthor Commented:
js - c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h
0
threadyAuthor Commented:
Zoppo - now I get the error - _MSC_EXTENSIONS already defined.
0
ZoppoCommented:
ok, sorry, I think I made a mistake regarding '_MSC_EXTENSIONS' - this one is always defined when compiling with the '/Ze'
option (Enable Language Extensions) which is on by default.

It maybe you compile the file as a C file, not as a C++

To check this open the 'Properties' for the file which generates this error when compiled, open options for 'Advanced' and check the 'Compile As' option.

ZOPPO
0
threadyAuthor Commented:
Zoppo - the file that generates this error is:  c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h

I should compile this one as a C file?
0
ZoppoCommented:
No, I meant the file which is compiled - the error appears in 'afx.h', but it appears while a .cpp file of your project is compiled.

The file's name should be shown in the line above the first error message ...
0
threadyAuthor Commented:
It's stdafx.h.  When I compile it as a C file, I get this error:  (comes from afx.h again)....

#ifndef __cplusplus
      #error MFC requires C++ compilation (use a .cpp suffix)
#endif
0
ZoppoCommented:
No, it's not 'afx.h' - you never compile '*.h' file directly, they are included by '*.cpp' files while compiled.

The default compile order is:
- stdafx.cpp (this includes 'stdafx.h' the first time)
- <all other .cpp files> (all of these usually include 'stdafx.h' too)

So, the output when compiling should be somehow like this:

1> ------ Build started: Project: <Your project's name>, Configuration: Debug Win32 ------
1> stdafx.cpp
1> ...
1> c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(736) : error C2061: syntax error : identifier '_Out_z_cap_'

before that last line (so in '1> ...') maybe further '*.cpp' appear - the last one is that which fails to compile (this even could be 'stdafx.h' - if so I would guess 'stdafx.cpp' is compiled as C instead of C++).

If this doesn't help please post the complete output from the first line up to the first error message you posted above ...

ZOPPO
0
threadyAuthor Commented:
>------ Build started: Project: USBHIDCardReaderThread, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(735) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(736) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(736) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(737) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(738) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(738) : error C2143: syntax error : missing ')' before ';'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(772) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(773) : error C2059: syntax error : ')'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(773) : error C2143: syntax error : missing ')' before 'const'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(946) : error C2061: syntax error : identifier '_Out_z_cap_'
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\afx.h(947) : error C2059: syntax error : ')'
0
ZoppoCommented:
Ok, so I guess you changed settings for 'stdafx.cpp' to compile as C instead of C++.

You should NOT compile anything as C if you don't really need to ...

BTW: Does your project include any '*.c' files or CPP files which differ from '*.cpp' (i.e. *.c++)? If so maybe VC 2008 automatically compiles them as C instead of C++
0
threadyAuthor Commented:
My project only has .cpp files and 1 .def  (which has the following in it):

; USBHIDCardReaderThread.def : Declares the module parameters.

LIBRARY      "USBHIDCardReaderThread.DLL"

EXPORTS
      DllCanUnloadNow     @1 PRIVATE
      DllGetClassObject   @2 PRIVATE
      DllRegisterServer   @3 PRIVATE
      DllUnregisterServer      @4 PRIVATE
0
ZoppoCommented:
The .def file shouldn't matter at all.

Please check if 'stdafx.cpp' is really compiled as C++ (via file's properties as described above) ...
0
js-profiCommented:
don't think that stdafx.cpp was compiled as C. Then the first errors would be much earlier than line 736.

i assume you have the stdafx.cpp and stdafx.h from vc6. do the following:

create a new dummy project in VS2008 with the wizard which is  most similar to your old project. I. e. if the old one was dialog-based create a dialog-based one. if it was sdi or mdi do the same. Take stdafx.h and stdafx.cpp from the new project and replace the stdafx.h and stdafx.cpp of the current project (save the original files somewhere). try to build. if you were lucky it wil work.
0
js-profiCommented:
for your information: stdafx.h is a so-called precompiled header which normally includes all winapi, mfc, atl ... then there is stdafx.cpp which contains nothing but include of stdafx.h. when stdafx.cpp was built it creates the precompiled-header file .pch which contains all object code of stdafx.h (you could say it compiled the header). then all other .cpp of project have first include stdafx.h and the compiler instead of compilng winapi and mfc every time again simply takes the .pch and puts it as it is to the object module .obj (machine code).
0
ZoppoCommented:
> don't think that stdafx.cpp was compiled as C. Then the first errors would be much earlier than line 736.
Yes, I agree, you're right. Sorry, dumb idea ...

But from the code I don't see how it could be that these errors occur - 'afx.h' includes 'new.h', 'new.h' includes 'crtdefs.h', 'crtdefs.h' includes 'sal.h' in which '_Out_z_cap_' is defined.


@thready: please check if maybe in your project's properties some wrong directories (i.e. absolute paths to VC 6 include files) are used, i.e. in 'General->Additional include directories' or 'Precompiled headers->Precompiled header file'
0
js-profiCommented:
my guess is that stdafx.h from vc6 contains some older macros like WIN32_MEAN_AND_CLEAN which could lead to needed header files were not included. or it includes some headers still existing in vc9 but not in the right order. or some needed macros like _WIN32_WINNT were not set at all or set to wrong windows version (i mean to remember that i had to add it for every new project).
0
threadyAuthor Commented:
ok - I decided to start from scratch - I created a new MFC DLL project with ATL Support.  I re-added my interface functions and properties and everything compiles with no errors and no warnings.

Now, to prepare for the files I think I need from the DDK, I add the following includes to the additional include directories (without doing anything else)
C:\WinDDK\7600.16385.0\inc\api;C:\WinDDK\7600.16385.0\inc\ddk;C:\WinDDK\7600.16385.0\inc\crt

And this gives me the following errors when I compile:
1>------ Build started: Project: USBHIDCardReaderThread, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C2065: '_S1max' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C2065: '_N' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C3861: '_Out_bytecap_post_bytecount_': identifier not found
.................
  Now I add my C++ class which will get called appropriately from the COM class- back to square 1:

1>------ Build started: Project: USBHIDCardReaderThread, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C2065: '_S1max' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C2065: '_N' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C3861: '_Out_bytecap_post_bytecount_': identifier not found
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C2144: syntax error : 'vo

After adding this class and adding
0
threadyAuthor Commented:
oops - please completely ignore my last message - I forgot to delete the rest (because I simplified what I was doing to present it to you guys to show the bare minimum of what causes these errors)
Here's what I should have wrote:
----------------------------------------------
ok - I decided to start from scratch - I created a new MFC DLL project with ATL Support.  I re-added my interface functions and properties and everything compiles with no errors and no warnings.

Now, to prepare for the files I think I need from the DDK, I add the following includes to the additional include directories (without doing anything else)
C:\WinDDK\7600.16385.0\inc\api;C:\WinDDK\7600.16385.0\inc\ddk;C:\WinDDK\7600.16385.0\inc\crt

And this gives me the following errors when I compile:
1>------ Build started: Project: USBHIDCardReaderThread, Configuration: Debug Win32 ------
1>Compiling...
1>stdafx.cpp
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C2065: '_S1max' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C2065: '_N' : undeclared identifier
1>c:\program files\microsoft visual studio 9.0\vc\atlmfc\include\atlalloc.h(227) : error C3861: '_Out_bytecap_post_bytecount_': identifier not found
.................
0
js-profiCommented:
what is the unknown type before _Out_z_cap_? or is _Out_z_cap_ the unknown type?
0
threadyAuthor Commented:
Well, now it's not that same error...  I removed my file that has that error in it, I'm just trying to do something more basic- be able to include the DDK include files needed (without even using them yet)...

As for Out_z_cap - that's in afx.h -->  it looks to me like some sort of MIDL parameter output specifier...
class AFX_NOVTABLE CException : public CObject
{
      // abstract class for dynamic type checking
      DECLARE_DYNAMIC(CException)

public:
// Constructors
      CException();   // sets m_bAutoDelete = TRUE
      explicit CException(BOOL bAutoDelete);   // sets m_bAutoDelete = bAutoDelete

// Operations
      void Delete();  // use to delete exception in 'catch' block

      virtual BOOL GetErrorMessage(_Out_z_cap_(nMaxError) LPTSTR lpszError, _In_ UINT nMaxError,
            _Out_opt_ PUINT pnHelpContext = NULL) const ;
      virtual BOOL GetErrorMessage(_Out_z_cap_(nMaxError) LPTSTR lpszError, _In_ UINT nMaxError,
            _Out_opt_ PUINT pnHelpContext = NULL);
      virtual int ReportError(UINT nType = MB_OK, UINT nMessageID = 0);

// Implementation (setting m_bAutoDelete to FALSE is advanced)
public:
      virtual ~CException() = 0;
      BOOL m_bAutoDelete;
#ifdef _DEBUG
      void PASCAL operator delete(void* pbData);
#if _MSC_VER >= 1200
      void PASCAL operator delete(void* pbData, LPCSTR lpszFileName, int nLine);
#endif
protected:
      BOOL m_bReadyForDelete;
#endif
};
0
js-profiCommented:
the _Out_z_cap_ most probably is a macro that can generate an additional argument - probably an array - . You could search where it is defined and check where it normally was not included and probably find out why it wasn't included in the current case. alternatively you simply can add _Out_z_cap_(n) to your preprocessor macros what should solve that error.

your ddk-errors: w wouldn't add the ddx include path to additional project includes but to the general include directories (tools - option - projects - vc-directories - include directories). here absolute paths are more appropriate. the problem i see with the ddk is if it contains same header files as the vc. then you get a mix which hardly could ever be built. check the files which gave errors whether they exist more than once.

0
ZoppoCommented:
Hi,

about that errors:

> error C2065: '_S1max' : undeclared identifier
> ...

Maybe you need to change the directory settings in VC 2008 so the DDK-folders 'override' the default VC 2008 directories (so just move them to the top of the list - if they don't exist in the list then add them)

ZOPPO
0
threadyAuthor Commented:
ok - I'd like to use the DDK directories for that project and prevent the ones for VC, but how do I set up just this project to do this?  (because I don't want to use the DDK for anything except this project)
0
ZoppoCommented:
You can add the DDK directories in the project's properties 'Additional include path' and select 'Ignore standard include path' in preprocessor settings. In this case maybe you need to add some of the standard include paths in the 'Additional include path' too ...
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
js-profiCommented:
better get you a ddk fitting to vs2008. i don't think you can mix vc6 ddk with vs2008. also absolute include paths should be put to general include paths. relative paths (relative to project folder like ..\other_project) should be added to additional project includes. never use two include folders where the same include files exists with different version. independent of the order you define them the vc precompiler may use the one or the other. different versions of header files included give heap corruption and crash.
0
js-profiCommented:
if you want the ddk only for project install it below or parallel to project. then you can use relative paths.

but actually don't think you've problems with a general defined ddk include path if it would fit to vs2008. those packages are well-defined and if you don't use it in another project it won't take header files from it.
0
threadyAuthor Commented:
Thanks guys, I now have a problem linking, I might post another question related to this...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.