473,320 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

6 errors in 3 lines of code :-)

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
Oct 18 '08 #1
19 3864
Anna Smidt wrote:
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
Oct 18 '08 #2
>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.
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
Oct 19 '08 #3
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!
Oct 19 '08 #4

"Anna Smidt" <a.*****@nospamgmail.comha scritto nel messaggio
news:OA****************@TK2MSFTNGP02.phx.gbl...
>
>>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.

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
Oct 19 '08 #5

"Anna Smidt" <a.*****@nospamgmail.comha scritto nel messaggio
news:uQ**************@TK2MSFTNGP02.phx.gbl...
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
Oct 19 '08 #6
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
Oct 20 '08 #7
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
Oct 20 '08 #8
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
Oct 20 '08 #9
Anna Smidt wrote:
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
Oct 20 '08 #10
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 ;-)

--
SvenC
Oct 20 '08 #11
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?
Oct 20 '08 #12
>
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
Oct 20 '08 #13
No, the project is done in VC9, not in VC6. It seems that my libraries
got mixed up (by myself).
Oct 20 '08 #14
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\WIN20 00_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)
Oct 20 '08 #15
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?

--
SvenC
Oct 20 '08 #16
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\WIN20 00_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

--
SvenC

Oct 20 '08 #17
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
Oct 20 '08 #18
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.hand put your defines in
front of that one.

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

--
SvenC
Oct 20 '08 #19
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
Oct 20 '08 #20

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Douglas Buchanan | last post by:
I am using the following code instead of a very lengthly select case statement. (I have a lot of lookup tables in a settings form that are selected from a ListBox. The data adapters are given a...
8
by: jon morgan | last post by:
OK, I'm going to be brave. There is a bug in VS.Net 1.1 that causes random compiler errors. I have raised this issue in posts at least three time in the past couple of months without attracting...
12
by: Russ | last post by:
Hello. My new dev machine is running XP Pro. In the past all equipment has only used Windows 2000. I have had a lot of problems getting my projects up and running on the new machine. The current...
10
by: electrixnow | last post by:
I have the following test code that opens and reads a file. The file is over 19000 lines long. The file contains two fields on each line: "text,text\n" I have placed a test that for loops up to...
5
by: hemdagem | last post by:
<% 2. option explicit 3. ' 4. set fs=CreateObject("Scripting.FileSystemObject") 5. set tfile=fs.CreateTextFile("c:\somefile.txt") 6. test = "Hello World!" 6. tfile.WriteLine(test) 7. ' 8....
20
by: cowboyrocks2009 | last post by:
Hi, I need help to automate my code to take data from input file. Also I need to create it as a function so that I can pass it to some other program. I am new to Java so having a bit limitation to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.