6 errors in 3 lines of code :-)

A

Anna Smidt

I have 6 errors in these 3 lines of code and - sorry - I am still too
newbie to help myself.
Anna

13: // CVidCapApp
14:
15: BEGIN_MESSAGE_MAP(CVidCapApp, CWinApp)
16: ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
17: END_MESSAGE_MAP()

Error 11 error C2059: syntax error : '&&' \haar\src\vidcap.cpp 16 VidCap
Error 12 error C2143: syntax error : missing ';' before '}'
\haar\src\vidcap.cpp 16 VidCap
Error 13 error C2059: syntax error : '}' \haar\src\vidcap.cpp 16 VidCap
Error 14 error C2143: syntax error : missing ';' before '{'
\haar\src\vidcap.cpp 17 VidCap
Error 15 error C2447: '{' : missing function header (old-style formal
list?) \haar\src\vidcap.cpp 17 VidCap
Error 16 error C2059: syntax error : '}' \haar\src\vidcap.cpp 17 VidCap
 
B

Bo Persson

Anna said:
I have 6 errors in these 3 lines of code and - sorry - I am still
too newbie to help myself.
Anna

13: // CVidCapApp
14:
15: BEGIN_MESSAGE_MAP(CVidCapApp, CWinApp)
16: ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
17: END_MESSAGE_MAP()

Error 11 error C2059: syntax error : '&&' \haar\src\vidcap.cpp 16

The compiler complains about an && on line 16, so we can only guess
that the macro adds a & and you shouldn't.


Bo Persson
 
A

Anna Smidt

The compiler complains about an && on line 16, so we can only guess
that the macro adds a & and you shouldn't.

I removed the &, and it worked :) But I am wondering why the original
author of the application made such mistake and did not notice it. I
mean shouldn't it have thrown him an error?

Now I have another problem... when compiling the app in release mode it
complains that it cannot find mfc42u.lib. I searched the internet and
most people said "Set compilation mode to ANSI, not Unicode". Because I
wanted to find out the real error I searched for mfc42u.lib on my hard
drive, but the only ones found were in

PSDK\...\AMD64
PSDK\...\IA64mfc
VC98\MFC\Lib

"Okay", I thought I seemed to have forgotten installing it. Put in my
DVD, and clicked on repair. To my surprise
ATL\MFC\Static Libraries Unicode was already checked. In my opinion this
means it's already installed. I'm horrified to wreck VC9 up by
re-installing it.

Anna
 
A

Anna Smidt

In fact I cannot reinstall it because it thinks that the MFC Unicode
things are already installed... Doh!
In the previous versions of VC++ there seemed to be a "Set Active
configuration" button in which one can change the app to use ANSI, but
in VC9 it isn't there anymore. What a stress!
 
G

Giovanni Dicanio

Anna Smidt said:
I removed the &, and it worked :) But I am wondering why the original
author of the application made such mistake and did not notice it. I mean
shouldn't it have thrown him an error?

Reading the MSDN documentation of MFC ON_COMMAND macro:

http://msdn.microsoft.com/en-us/library/a5f1bcxd.aspx

it is clear that the explicit & is needed:

<code sample>

BEGIN_MESSAGE_MAP(CMFCListViewDoc, CDocument)
ON_COMMAND(ID_MYCOMMAND, &CMFCListViewDoc::OnMycommand)
END_MESSAGE_MAP()

</code sample>

So: would it be possible that you are using the wrong header files for MFC
(maybe you are using VC6 MFC headers in your VC9 project) ?

Or should you adjust the library path? (Kind of the initial error of header
files that Sven correctly diagnosed recently?)

Now I have another problem... when compiling the app in release mode it
complains that it cannot find mfc42u.lib.

MFC42 is the MFC of VC6. MFC of VC9 is MFC90. You should link with
mfc90u.lib (in
<Visual Studio 2008 Installation Directory>\VC\atlmfc\lib).

Giovanni
 
G

Giovanni Dicanio

In the previous versions of VC++ there seemed to be a "Set Active
configuration" button in which one can change the app to use ANSI, but in
VC9 it isn't there anymore. What a stress!

In Solution Explorer select your project Properties, then go to node:

Configuration Properties --> General

then modify the "Character Set" field.

Giovanni
 
A

Anna Smidt

So: would it be possible that you are using the wrong header files for MFC
(maybe you are using VC6 MFC headers in your VC9 project) ?

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

Are these VC9 or VC6 headers? I think they are used from VC6 till VC9,
right?

MFC42 is the MFC of VC6. MFC of VC9 is MFC90. You should link with
mfc90u.lib (in
<Visual Studio 2008 Installation Directory>\VC\atlmfc\lib).

Yes, under Options/ VC++ Directories I can see
$(VCInstallDir)atlmfc\lib

I think you are right about this:
<<
Or should you adjust the library path? (Kind of the initial error of header
files that Sven correctly diagnosed recently?)But I haven't found out yet how to do it. I will be struggeling till the
morning again :)

Anna
 
A

Anna Smidt

I have just noticed something strange:

Under "Include files" I found
C:\Programs\Microsoft Platform SDK for Windows Server 2003 R2\Include\mfc

I then found AFXWIN.H and it reads:
// Copyright (C) 1992-1998 Microsoft Corporation

So I guess that was the bad boy...
I have removed this include directory.

Anna
 
A

Anna Smidt

Can somebody confirm that this is a compiler error that is correctly
thrown when working with XP or if it's something that's thrown because I
did something wrong?

// Note: WINDOWS.H already included from AFXV_W32.H
#ifndef NTDDI_LONGHORN
#define NTDDI_LONGHORN 0x06000000
#if (WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)
#error Your version of the Windows SDK is earlier than 6.0. Try setting
the 'WINVER' and '_WIN32_WINNT' definitions in your project to less than
0x0600.
#endif
#endif

Anna
 
B

Bo Persson

Anna said:
Can somebody confirm that this is a compiler error that is correctly
thrown when working with XP or if it's something that's thrown
because I did something wrong?

// Note: WINDOWS.H already included from AFXV_W32.H
#ifndef NTDDI_LONGHORN
#define NTDDI_LONGHORN 0x06000000
#if (WINVER >= 0x0600) || (_WIN32_WINNT >= 0x0600)
#error Your version of the Windows SDK is earlier than 6.0. Try
setting the 'WINVER' and '_WIN32_WINNT' definitions in your project
to less than 0x0600.
#endif
#endif

This has nothing to do with where you compile, but what system you
target. Windows 6.0 is Vista.

Do you have/want to use a Vista SDK?


Bo Persson
 
S

SvenC

Hi Anna,
I have just noticed something strange:

Under "Include files" I found
C:\Programs\Microsoft Platform SDK for Windows Server 2003
R2\Include\mfc

I then found AFXWIN.H and it reads:
// Copyright (C) 1992-1998 Microsoft Corporation

That path points to an old SDK which is known as the last usable
SDK for VC6. But from your earlies posts I got the impression
that you have a project converted from VC6 to VC9, right?

You will need to check all your project properties for C/C++ and
Linker to find and remove those wrong old paths.

There are also defaults in VS2008 Tools->Options->Projects
and Solutions->VC++ Directories. I hope you didn't change too
much in that area as that would affect all your projects.

When it comes to using the SDK from VC9 you should not need
to add include or lib paths manually as they should have been
setup for you by VS2008 Setup or from a separately installed
WinSDK.

If you have some garbled settings in your converted project you
could easily create a new VC9 project of the same type as your
VC6 project (Win32, MFC, ATL, Pocket or whatever you got)
and compare these project settings with those of your converted
project. That might give you an idea where to change what.

But do these changes on a copy of your project so that you can
get back when you changed too much ;-)
 
A

Anna Smidt

Hi Sven!
I did change those paths, but not in the project settings, but on the
VC++ directories... I will post what I have now, okay?
 
A

Anna Smidt

This has nothing to do with where you compile, but what system you
target. Windows 6.0 is Vista.

Do you have/want to use a Vista SDK?

The original project seems to target Vista. I would like to be able to
compile it on XP.
I thought about changing these lines to the XP WINVER so that I can
compile it, but it appears in so many place that I got scared.

Anna
 
A

Anna Smidt

No, the project is done in VC9, not in VC6. It seems that my libraries
got mixed up (by myself).
 
A

Anna Smidt

These are my VC++ Directories.

----Executables
D:\Programs\Microsoft DirectX SDK (August 2008)\Utilities\Bin\x86
$(VCInstallDir)bin
$(WindowsSdkDir)\bin
$(VSInstallDir)Common7\Tools\bin
$(VSInstallDir)Common7\tools
$(VSInstallDir)Common7\ide
$(FrameworkSDKDir)bin
$(FrameworkDir)$(FrameworkVersion)
$(VSInstallDir)
$(SystemRoot)\SysWow64
$(FxCopDir)
$(PATH)

---Include files
D:\Programs\Microsoft DirectX SDK (August 2008)\Include
C:\Programs\Microsoft DirectX SDK (August 2007)\Include
C:\Programs\OpenCV\otherlibs\highgui
C:\Programs\OpenCV\cxcore\include
C:\Programs\Microsoft Platform SDK for Windows Server 2003 R2\Include
C:\Programs\OpenCV\interfaces\ch\OpenCV\include
C:\Programs\OpenCV\cv\include
C:\Programs\Microsoft Platform SDK for Windows Server 2003
R2\Samples\Multimedia\DirectShow\BaseClasses
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include

---References (What are "references" in this case, btw?)
$(FrameworkDir)$(FrameworkVersion)
$(VCInstallDir)atlmfc\lib
$(VCInstallDir)lib

---Library files
C:\Programs\Microsoft Platform SDK for Windows Server 2003
R2\Samples\Multimedia\DirectShow\BaseClasses\WIN2000_RETAIL (Thanks to
Sven for explaining me nmake :)
C:\Programs\OpenCV\lib
$(VCInstallDir)lib
$(VCInstallDir)atlmfc\lib
$(VCInstallDir)atlmfc\lib\i386
$(WindowsSdkDir)\lib
$(FrameworkSDKDir)lib
$(VSInstallDir)
$(VSInstallDir)lib

---Source files
C:\Programs\OpenCV\otherlibs\highgui
C:\Programs\OpenCV\cvaux\src
$(VCInstallDir)atlmfc\src\mfc
$(VCInstallDir)atlmfc\src\mfcm
$(VCInstallDir)atlmfc\src\atl
$(VCInstallDir)crt\src

---Exclude directories (Why should I exclude directories, btw, even if
they are named "include", like "$(VCInstallDir)include"?)
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include
$(FrameworkDir)$(FrameworkVersion)
 
S

SvenC

Hi Anna,
I did change those paths, but not in the project settings, but on the
VC++ directories... I will post what I have now, okay?

Kind of okay... I would not change the general VC++ directories to
point to an older SDK. That asks for trouble, when you compile
new VC9 projects which expect to be build with a current SDK.

Converting a VC6 project to VC9 should also include to get it
compiled with the new SDK.

And I would not recommend this kind of porting as a good task
to start learning C++ and the C++ libraries coming with VC9.

Is it absolutely necessary for you to start with an old VC6 project?
How about starting with a fresh project created with one of the
VC project wizards and adding code there as you need?
 
S

SvenC

Hi Anna,
These are my VC++ Directories.
----Executables

those looked OK
---Include files
D:\Programs\Microsoft DirectX SDK (August 2008)\Include
C:\Programs\Microsoft DirectX SDK (August 2007)\Include

Are you sure that two SDK include dirs are needed? Isn't 2008
sufficient?
C:\Programs\OpenCV\otherlibs\highgui
C:\Programs\OpenCV\cxcore\include
C:\Programs\Microsoft Platform SDK for Windows Server 2003 R2\Include
C:\Programs\OpenCV\interfaces\ch\OpenCV\include
C:\Programs\OpenCV\cv\include
C:\Programs\Microsoft Platform SDK for Windows Server 2003
R2\Samples\Multimedia\DirectShow\BaseClasses

Are you sure you need the Win2003 R2 includes?
$(VCInstallDir)include
$(VCInstallDir)atlmfc\include
$(WindowsSdkDir)\include
$(FrameworkSDKDir)include

I would expect the last two includes should replace the older Win2003 R2
includes.
---References (What are "references" in this case, btw?)

Don't know
---Library files
C:\Programs\Microsoft Platform SDK for Windows Server 2003
R2\Samples\Multimedia\DirectShow\BaseClasses\WIN2000_RETAIL (Thanks to
Sven for explaining me nmake :)

Maybe I didn't explain well enough ;-) Try to remove the Win2003 R2 path
and use the latest DirectX SDK instead. You shouldn't mix includes and libs
of
different SDKs
---Exclude directories (Why should I exclude directories, btw, even if
they are named "include", like "$(VCInstallDir)include"?)

Don't know
 
A

Anna Smidt

Okay, thanks Sven!
I must make it clear that the project wasn't done in VC6, but in VC9,
and now that my problems are resolved by removing these old VC6
references, it seems to work... up to the fact that the author targetted
Vista, and I don't know how to change that. I went through all menues of
the IDE but couldn't find any settings for that.

Anna
 
S

SvenC

Hi Anna,
Okay, thanks Sven!
I must make it clear that the project wasn't done in VC6, but in VC9,
and now that my problems are resolved by removing these old VC6
references, it seems to work... up to the fact that the author
targetted Vista, and I don't know how to change that. I went through
all menues of the IDE but couldn't find any settings for that.

Do you have a targetver.h? That is created from new VC9 wizards and
there you can change WINVER and _WIN32_WINNT to 0x0501 for
XP.

If that doesn't exist you might have a precompile header, often named
stdafx.h. You could set the defines at the beginning of that file.

Otherwise you would have to look for other global header. Maybe
some header which include <windows.h> and put your defines in
front of that one.

0x0500 is for Win2000, 0x0501 for WinXP, 0x0502 for Win2003
 
A

Anna Smidt

Sven, you are a charm!!
I had wrong includes... I removed ...

C:\Programs\Microsoft Platform SDK for Windows Server 2003 R2\Include

.... as you said, and all errors were gone!!
Oh man, you're gold! Your wife can be proud of you :))

Anna
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top