Can't Build 4coder_casey.cpp

I can't build 4coder_casey.cpp which comes bundled in version 4.0.27. It throws a bunch of errors when compiling with buildsuper.bat.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
c:\users\adin\programs\4coder\src\4coder_casey.cpp(752): error C2220: warning treated as error - no 'object' file generated
c:\users\adin\programs\4coder\src\4coder_casey.cpp(752): warning C4456: declaration of 'access' hides previous local declaration
c:\users\adin\programs\4coder\src\4coder_casey.cpp(720): note: see declaration of 'access'
c:\users\adin\programs\4coder\src\4coder_casey.cpp(763): error C2065: 'null_location': undeclared identifier
c:\users\adin\programs\4coder\src\4coder_casey.cpp(923): warning C4456: declaration of 'Token' hides previous local declaration
c:\users\adin\programs\4coder\src\4coder_casey.cpp(918): note: see declaration of 'Token'
c:\users\adin\programs\4coder\src\4coder_casey.cpp(949): warning C4456: declaration of 'Token' hides previous local declaration
c:\users\adin\programs\4coder\src\4coder_casey.cpp(944): note: see declaration of 'Token'
c:\users\adin\programs\4coder\src\4coder_casey.cpp(978): error C3861: 'get_range': identifier not found
c:\users\adin\programs\4coder\src\4coder_casey.cpp(1809): error C3861: 'change_font': identifier not found

I got it down to just one error by commenting out some unused lines and renaming some variables.

For
1
c:\users\adin\programs\4coder\src\4coder_casey.cpp(752): warning C4456: declaration of 'access' hides previous local declaration

I commented out the second deceleration as its value wasn't changed in the code.

Original
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
if(append(&command, "build.bat"))
{
    unsigned int access = AccessAll;
    View_Summary view = get_active_view(app, access);
    exec_system_command(app, &view,
                        buffer_identifier(GlobalCompilationBufferName, (int)strlen(GlobalCompilationBufferName)),
                        dir.str, dir.size,
                        command.str, command.size,
                        CLI_OverlapWithConflict);
    lock_jump_buffer(GlobalCompilationBufferName, str_size(GlobalCompilationBufferName));
}

Edited
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
if(append(&command, "build.bat"))
{
    //unsigned int access = AccessAll;
    View_Summary view = get_active_view(app, access);
    exec_system_command(app, &view,
                        buffer_identifier(GlobalCompilationBufferName, (int)strlen(GlobalCompilationBufferName)),
                        dir.str, dir.size,
                        command.str, command.size,
                        CLI_OverlapWithConflict);
    lock_jump_buffer(GlobalCompilationBufferName, str_size(GlobalCompilationBufferName));
}

The same worked for
1
c:\users\adin\programs\4coder\src\4coder_casey.cpp(763): error C2065: 'null_location': undeclared identifier
and
1
c:\users\adin\programs\4coder\src\4coder_casey.cpp(1809): error C3861: 'change_font': identifier not found

I'm assuming that they were just using deprecated APIs.

For the errors with Token I renamed the local variable to localToken in both cases.
1
2
c:\users\adin\programs\4coder\src\4coder_casey.cpp(923): warning C4456: declaration of 'Token' hides previous local declaration
c:\users\adin\programs\4coder\src\4coder_casey.cpp(949): warning C4456: declaration of 'Token' hides previous local declaration

Original
 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
token Token = PeekToken(Tokenizer);
if((Token.Type == Token_Minus) ||
  (Token.Type == Token_Number))
{
    Result = ParseConstant(Tokenizer);
    token Token = PeekToken(Tokenizer);
    if(Token.Type == Token_ForwardSlash)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Divide, Result, ParseNumber(Tokenizer));
    }
    else if(Token.Type == Token_Asterisk)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Multiply, Result, ParseNumber(Tokenizer));
    }
}

...

token Token = PeekToken(Tokenizer);
if((Token.Type == Token_Minus) ||
  (Token.Type == Token_Number))
{
    Result = ParseMultiplyExpression(Tokenizer);
    token Token = PeekToken(Tokenizer);
    if(Token.Type == Token_Plus)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Add, Result, ParseMultiplyExpression(Tokenizer));
    }
    else if(Token.Type == Token_Minus)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Subtract, Result, ParseMultiplyExpression(Tokenizer));
    }
}

Edited
 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
token Token = PeekToken(Tokenizer);
if((Token.Type == Token_Minus) ||
  (Token.Type == Token_Number))
{
    Result = ParseConstant(Tokenizer);
    token localToken = PeekToken(Tokenizer);
    if(localToken.Type == Token_ForwardSlash)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Divide, Result, ParseNumber(Tokenizer));
    }
    else if(localToken.Type == Token_Asterisk)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Multiply, Result, ParseNumber(Tokenizer));
    }
}

...

token Token = PeekToken(Tokenizer);
if((Token.Type == Token_Minus) ||
  (Token.Type == Token_Number))
{
    Result = ParseMultiplyExpression(Tokenizer);
    token localToken = PeekToken(Tokenizer);
    if(localToken.Type == Token_Plus)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Add, Result, ParseMultiplyExpression(Tokenizer));
    }
    else if(localToken.Type == Token_Minus)
    {
        GetToken(Tokenizer);
        Result = AddNode(CalcNode_Subtract, Result, ParseMultiplyExpression(Tokenizer));
    }
}

Now we get to the issue I couldn't solve.

1
c:\users\adin\programs\4coder\src\4coder_casey.cpp(978): error C3861: 'get_range': identifier not found

From the code I inferred that it was supposed to get the range of text available in the view but I couldn't figure out how to get that from the View_Summary struct. When trying to write my own get_range function this is where I got stuck. It also didn't help that I wasn't exactly sure what get_range was supposed to do.

I know I could have solved most of the errors by removing the warnings, but I wanted it to compile according to the intended build system.

If anyone here can help that would be great!

Edited by Adin W-T on Reason: Initial post
For your final error just change the name to "get_view_range" the name "get_range" was becoming uncomfortably overloaded.

Also, I apologize for not updating 4coder_casey.cpp before shipping it. I fell out of the habit of keeping it current when I stopped shipping it and forgot to go through it again for this build. Thanks for posting all this info on how to fix it! Everything you suggested looks okay to me.
Sorry for never posting a follow up. That worked perfectly. Thank you so much.