OCC 62 sample compilation for new users on VC8

Thinks to "Philippe Carret" for it's message "OCC 51 sample compilation for new users"
There is another problem when compiling the project mfcsample under VC8.
List of errors :
1/ ...\mfc\common\isession2d\isession2d_shape.cpp(63) : error C2065: 'i' : undeclared identifier
2/ ...\mfc\common\occ_2dview.cpp(668) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
3/ ...\mfc\common\importexport\importexport.cpp(365) : error C2065: 'i' : undeclared identifier

for the erroe 1 and 3, it's not difficult.
the error 2, in line :
static LastIsGridActiveStatus = Standard_True;
I assume that LastIsGridActiveStatus is bool.

it's Correct ?

Gennady Khokhorin's picture

Its weird. Got the same compiler errors.
Looks like latest 6.3.0 (Sept) was not being updated since version 6.2 (March)

msvc8.0

Gennady Khokhorin's picture

I'm guessing it should be Standard_Boolean

ronan's picture

I have also the same problem.
Any one has a idea or no one use it on windows???

Paul Jimenez's picture

The source of that problem is that the examples use a very old syntax from an old C standard that is not supported by C++ (which is more than 10 years old already). The two common problems found in the examples are default-int and variable scope in for loops.

Default-int looks like this (taking the 'static' example):

static SomeVar = SomeValue; // SomeVar is 'int' by default (unsupported in C++)

To fix that, just add the missing int like this:

static int SomeVar = SomeValue;

The problem that deals with scope is like this:

for (int i = ...; ...; ...) { ... } // i is only known in the for loop
for (i = ...; ...; ...) { ... } // i is no longer known here

That is not supported by C++ either. The old behavior was that 'i' would still be visible after the for loop. To fix that the code needs to be changed like this:

for (int i = ...; ...; ...) { ... }
for (int i = ...; ...; ...) { ... } // there's an instance of i now for this for loop

That should get the code to compile and run.

ronan's picture

Ok,
Thank you Paul, for your answer.