Syntax error 'return' etc...

Sorry if this question will be answered with a trivial solution, but I really can't work it out.

I'm developing this console application with VS2010 on a 32bit Win7.

I don't think the error comes from the include files, since the build is working with them on another simple project (with the same project properties).

Here's the code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "stdio.h"
#include "sapclassbasic.h"


// Static Functions
static void XferCallback(SapXferCallbackInfo *pInfo);




// Example program
int main(int argc, char* argv[])
{
	BOOL success = TRUE ;

	// Allocate acquisition object
	SapAcquisition *pAcq = new SapAcquisition(SapLocation("X64-CL_1", 0), "MyCamera.ccf");
	
	// Allocate buffer object, taking settings directly from the acquisition
	SapBuffer *pBuffer = new SapBuffer(1, pAcq);
	
	// Allocate view object, images will be displayed directly on the desktop
	SapView *pView = new SapView(pBuffer, SapHwndDesktop);
	
	// Allocate transfer object to link acquisition and buffer
	SapTransfer *pTransfer = new SapTransfer(XferCallback, pView);
	pTransfer->AddPair(SapXferPair(pAcq, pBuffer));

	// Create resources for all objects
	success = pAcq->Create();
	success = pBuffer->Create();
	success = pView->Create();
	success = pTransfer->Create();

	// Start a continuous transfer (live grab)
	success = pTransfer->Grab();
	printf("Press any key to stop grab\n");
	getchar();

	// Stop the transfer and wait (timeout = 5 seconds)
	success = pTransfer->Freeze();
	success = pTransfer->Wait(5000);
	printf("Press any key to terminate\n");
	getchar();

	// Release resources for all objects
	success = pTransfer->Destroy();
	success = pView->Destroy();
	success = pBuffer->Destroy();
	success = pAcq->Destroy();
	
	// Free all objects
	delete pTransfer;
	delete pView;
	delete pBuffer;
	delete pAcq;
	return 0;

}

// Transfer callback function is called each time a complete frame is transferred.
// The function below is a user defined callback function.
void XferCallback(SapXferCallbackInfo *pInfo)
{
	// Display the last transferred frame
	SapView *pView = (SapView *) pInfo->GetContext();
	pView->Show();
}


And here's the error I get:

1
2
3
4
5
6
7
8
9
10
11
1
1>Build started 17/12/2014 12:00:03.
1>InitializeBuildStatus:
1>  Creating "Debug Sapera\helloworld3.unsuccessfulbuild" because "AlwaysCreate" was specified.
1>ClCompile:
1>  HelloWorld3.cpp
1>c:\users\cocci lab\documents\visual studio 2010\projects\helloworld3\helloworld3\helloworld3.cpp(11): error C2059: syntax error : 'return'
1>c:\users\cocci lab\documents\visual studio 2010\projects\helloworld3\helloworld3\helloworld3.cpp(13): error C2059: syntax error : '}'
1>c:\users\cocci lab\documents\visual studio 2010\projects\helloworld3\helloworld3\helloworld3.cpp(13): error C2143: syntax error : missing ';' before '}'
1>c:\users\cocci lab\documents\visual studio 2010\projects\helloworld3\helloworld3\helloworld3.cpp(13): error C2059: syntax error : '}'
1>
1>Build FAILED.


Thanks a lot in advance.
i suspect the issue is in another file that you haven't posted e.g. inside the file that contains your 'SapXferCallbackInfo' class.

also, why do you create a bool and do nothing with it? ('success')?
Last edited on
what is the content of "sapclassbasic.h"?

Also try to change line 1 into #include<iostream>
Last edited on
Mutexe:
I thought it too, but even commenting out that function, and the lines where it's involved, the result does not change. Always giving me the error at the level of main.

Tanezavm:
It's a library to control a Teledyne camera and frame grabber. But it works perfectly on another similar code.

if you comment out the contents of your main and build what happens then?
If that builds I would uncomment out lines 14-17 and rebuild.

Keep doing that until you find the offending line.

I know you say:
But it works perfectly on another similar code.

but i think that's the culprit. It must be.
For future reference, I found the issue: I copied two lines of code from a PDF file and the CRLF line endings weren't coherent/consistent.

Found it randomly by working on the project after rebooting, VS warned me at opening.

It would be nice to have more informative error messages...
Topic archived. No new replies allowed.