4coder » Forums » Yet another problem :shy:
Raech
Rafael
4 posts
#12671 Yet another problem :shy:
3 months, 3 weeks ago Edited by Rafael on July 30, 2017, 4:57 a.m.

Hello! I'ts me again :shy:

I've upgraded my patreon pledge to be a super~ and while i was trying to buildsuper.bat i got the following error :



and i honestly didn't even begin to change anything yet, i just tried to run the .bat


thanks for the attention!
keep up with the awesome work :D


p.s :

I've successfully compiled it removing the part that was messy
I don't really understand whats going on there but it was checking for >0 then >1 so I removed the >1 part and it was fine... (but i dunno if its really supposed to be like this, because maybe I'm just breaking some stuff down the road)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
static void
default_4coder_side_by_side_panels(Application_Links *app, char **command_line_files, int32_t file_count)
{
    Buffer_Identifier left = buffer_identifier(literal("*scratch*"));
    Buffer_Identifier right = buffer_identifier(literal("*messages*"));
    
    if (file_count > 0){
        char *name = command_line_files[0];
        int32_t len = str_size(name);
        left = buffer_identifier(name, len);
#if 0        
        if (file_count > 1){   //  problem was in this if
            char *name = command_line_files[1];
            int32_t len = str_size(name);
            right = buffer_identifier(name, len);
        }
#endif
    }
    
    default_4coder_side_by_side_panels(app, left, right);
}




p.s 2

Nevermind it was just me being retarded, if i actually read the code i could've fixed it, the compiler was just complaining about a new initialization of the same variable .. >_>



can close/delete this please :D
mmozeiko
Mārtiņš Možeiko
1503 posts
1 project
#12673 Yet another problem :shy:
3 months, 3 weeks ago Edited by Mārtiņš Možeiko on July 30, 2017, 5:42 a.m.

Raech
about a new initialization of the same variable .. >_>

No. Its not the same variable. Compiler is complaining that there are two different variables with same name. That is warning about a potential bug.

"New initialization" doesn't make sense. You can initialize variables only once. So there are two initialziations for two variables.

Imagine code like this:
1
2
3
4
5
6
7
8
int x = 1;
...
if (whatever)
{
   int x = 2;
   ...
   printf("%i\n", x);
}
What if "..." is a lot of lines of code, and when you write line with printf you forgot that that there is second "int x=2" variable inside if statement. You maybe wanted to print out the first "int x=1" variable. That is what compile is warning you about - in other words "hey look at this place, it looks very suspicious, same function has two different variables with same name, are you sure you really want this?"

In most cases the fix is to rename variable to have different name, and carefully check all uses of variable - did you want to use first instance or second instance.
Raech
Rafael
4 posts
#12674 Yet another problem :shy:
3 months, 3 weeks ago Edited by Rafael on July 30, 2017, 6 a.m.

oh...I guess I worded that bad, but I still had gotten it incorrectly anyway, thanks for clarifying for me!

I went back in there and changed to name2 for now
:o
Mr4thDimention
Allen Webster
283 posts
2 projects

Heyo

#12687 Yet another problem :shy:
3 months, 3 weeks ago

This isn't a problem with anything you did.

I try to run the custom code through all of the compilers people might use to make sure it works, but sometimes I miss something, and thats what happened here.