Use this tag for questions related to redeclaration, such as overwriting a function.
Questions tagged [redeclaration]
64 questions
1
vote
2 answers
C++ Confusing scope of redeclared variables in for loop
The following while loop does not terminate. This is because the variable x is being re-declared inside the while loop. But I don't understand why in the second iteration onward, the statements x<10 and y=x considers the x defined in the outer scope…

VINOD S
- 71
- 2
1
vote
0 answers
Redeclaration of enumerator - conflicting types
I'm having a problem with my enums..
In my header file i declare the enums as followed:
/********************************************
* TYPEDEFINES
*******************************************/
typedef enum {not_received, received, restart}…

MrG
- 11
- 3
1
vote
2 answers
error: redeclaration of ‘y2’ with no linkage
I am tring to create a program that recieves integer values and converts them into 2's complement integers using atoi, and determines what type of turn was made. Here is my code:
#include
#include
int turn(int turn, int a1, int…

user190494
- 509
- 2
- 8
- 20
1
vote
2 answers
Does PHP sometimes ignore function redeclarations?
I am working on a website with a few friends, and recently, users have complained about a fairly important feature doing nothing but return a blank page. This only happens for some users, while other users are able to use it perfectly fine.
I…

Neko
- 3,550
- 7
- 28
- 34
0
votes
0 answers
Android Studio redeclaration error when compiling release while having Kotlin Poet generated classes
My app uses Kotlin Poet to generate some classes at compile time. These classes are generated in app/build/generated/source/kaptKotlin [main] and there in two subfolders debug."packagename" and release [main]/"packagename", depending on if I compile…

Michael Konz
- 503
- 1
- 3
- 20
0
votes
2 answers
C++ Static variable inside function cannot be changes
Can someone please explain to me the following.
static_outer works as expected. When the print_str() function is called, static_outer is assigned the value from the parameter and then printed to output.
static_inner "misbehaves" a little. It is also…

Lukáš Řádek
- 1,273
- 1
- 11
- 23
0
votes
2 answers
Typedef after incomplete type definition
I'm need to declare incomplete type (may it be siginfo_t) in header, and in source import some system header (sys/signal.h), that defines that type.
So, here is the problem:
// a.h
struct siginfo_t;
void foo(siginfo_t*);
// a.cpp
#include…

Саша Новожилов
- 31
- 8
0
votes
0 answers
Is redeclaration of global objects legal or illegal in C?
In certain circumstances, the C language allows you to declare an object such as a variable without defining it.
This can be done using the keyword ‘extern’ or through the tentative definition rule for global variables (although in this case I am…

Bey Réda
- 57
- 5
0
votes
0 answers
Android Studio Kotlin redeclaration error with actual/expect
Android Studio reports a redeclaration error with Kotlin objects even though Gradle builds the project correctly.
I have this in my commonMain
expect object ApplicationConfig {
val url1: String
val url2: String
val url3: String
}
I have…

Okko Kauhanen
- 1
- 4
0
votes
1 answer
Having trouble making my imported modules be const
I'm working on updating a (Thunderbird) extension in Javascript. In a JS file of mine, I have:
var { ObjectUtils } = ChromeUtils.import("resource://gre/modules/ObjectUtils.jsm");
now, I know that var is frowned upon, and that we like const, and…

einpoklum
- 118,144
- 57
- 340
- 684
0
votes
2 answers
Changing the scope of "let" declaration
I want to run a script multiple time, and I don't know whether it's first run or not - so I have to ask, and if so, I'll declare it:
if (typeof variable == undefined) { let variable = new Set(); }
Unfortunately
1.) re-declaring with let variable;…

cncDAni3
- 53
- 1
- 8
0
votes
2 answers
Re-assign/declare a const variable in a JavaScript for-loop and save it more than one time with different values?
I know that we can't re-assign or redeclare a const variable in JavaScript as it's constant. but what about that code ?!
const myCustomDiv = document.createElement('div');
for (let i = 1; i <= 200; i++) {
const newElement =…

Migo
- 31
- 4
0
votes
1 answer
SWIFT Xcode11.5 - array append not working in ViewController
Hi I'm trying to declare a simple array variable inside class ViewController. But when I try to append value to it, Xcode just keep giving me "Consecutive declarations on a line must be separated by ';' ... Invalid redeclaration of 'mylist()'"
var…

Alb
- 11
- 1
0
votes
1 answer
How to avoid redeclaration of constants in python 3
We have a file, where we have constant definitions and there are a lot of them. When there is a name collision, python assigns a new value to it without warning that constant with such name already exists. This is a potential source of bugs. Static…

Najiva
- 142
- 8
0
votes
2 answers
Why constant declaration in function declaration doesn't throw an error?
I'm learning from MDN, so here's code like that, and It blows my mind why the choice variable from const choice = select.value; line is used as constant here. I believe that .value might be change and constants cannot be change after assignment...…

Beqa shekiladze
- 65
- 1
- 7