Questions tagged [redefinition]

276 questions
5
votes
1 answer

Why is this compiling successfully?

What is the reason which why this code compile : #include using namespace std; class being { public: void running(char c) { cout << "No one know "; } }; class human :public being { public: using being::running; void…
5
votes
2 answers

C, "conflicting types for... " error

Before I continue, here is the code which is giving me an error: #define numScores 3 // the number of test scores which a student will have struct btreenode{ int studentID; // the ID number of the student at the current…
jlzizmor
  • 53
  • 1
  • 1
  • 3
4
votes
1 answer

Typedef redefinition error when trying to build XCode project for release

I can build my project in Xcode(4.2) for debugging without issues, but when I want to build it for release (build for archiving) I get error:"Typedef redefinition with different types (unsigned int vs unsigned long)". Problematic code is: #ifdef…
ivan glisic
  • 53
  • 1
  • 1
  • 4
4
votes
2 answers

How is typedef redefinition meant to work in C11?

I read that in C11 typedef redefinition is allowed, as long as the definitions are the same. However the following code typedef struct { int x; } a_t; typedef struct { int x; } a_t; int main(int argc, char* argv[]) { a_t a; return…
lipi
  • 53
  • 4
4
votes
3 answers

variable redefinition, embedded c

I'm working on an embedded c project and am having issues with global variable redefinition. I've split up the function declarations and definitions into a handful of .h and .c files. Many of these functions need access to global variables, which…
Trey
  • 348
  • 5
  • 16
4
votes
2 answers

Redefining fputc function when using arm-none-eabi toolchain

We have an STM32 C/C++ project and we have redefined the weak fputc(int, FILE *) function in order to redirect printf output to some UART channel. Up until now, we were building the project under IAR with the IAR compiler. The logging through UART…
Ril Dank
  • 105
  • 1
  • 11
4
votes
2 answers

GCC does not complain about re-definition of external variable?

This simple code (MCVE): #include int a = 3; int main(){ printf("%d\n", a); return 0; } int a; // This line To my surprise, GCC (MinGW GCC 4.8.2, 4.9.2 and 6.3.0) does not give any error, not even warnings about the marked line!…
iBug
  • 35,554
  • 7
  • 89
  • 134
4
votes
3 answers

C++ 'class' type redefinition error

I'm learning Visual C++ and building the "Sketcher" example program from Ivor Horton's Visual book, and I was able to generate the toolbars, menu icons, prompts, and a rectangle drawn with a few hard-coded points. After adding some mouse handlers…
user3362735
4
votes
3 answers

How do I print out a tcl proc?

Given a simple tcl proc like proc foo {a b} {puts "$a $b"} What tcl command can I use to print out the procedure foo ... that is I want the text of the proc back ... For instance: % proc foo {a b} {puts "$a $b"} % foo a b a b % puts $foo …
Xofo
  • 41
  • 1
  • 2
4
votes
1 answer

Why would a non-constant static member have multiple definitions?

C++ forces the programmer to define a non-constant static member outside the class, and the reason for this that I keep seeing is that if the static member was defined inside the class, this would result in multiple definitions for the static…
Kacy
  • 3,330
  • 4
  • 29
  • 57
4
votes
1 answer

Multiple inclusion error, can't find a solution

I've recently been struggling with multiple file inclusion errors. I'm working on a space arcade game and have divided my classes/objects into different .cpp files and to make sure everything still works fine together I have build the following…
Joey Dewd
  • 1,804
  • 3
  • 20
  • 43
3
votes
1 answer

Why this code is NOT causing redefinition error?

#include struct Foo { template Foo(std::initializer_list) {} template Foo(std::initializer_list) {} }; struct Bar { using BarAlias = Bar; }; int main() { …
mikerru
  • 33
  • 3
3
votes
3 answers

C++: function inside class for multiple variable values

a bit of a noob problem. Inside a class called 'cell', I have an enum 'Example' say typedef enum Example { E1=0, E2, E3, E4 }; Example inputValueE; Also I have a function inside class as follows void…
the_prince
  • 33
  • 1
  • 3
3
votes
3 answers

Which Python object comparison methods to redefine to make sorted() work?

I feel this question must have been asked before but I could not find an answer. Suppose I want to implement a Python class whose objects are sortable with sorted(). Do I have to reimplement all methods like __lt__(), __gt__(), etc.? What is the…
DYZ
  • 55,249
  • 10
  • 64
  • 93
3
votes
3 answers

function redefinition: const parameter

1. In global scope, this gives error: redefinition of 'f' #include using namespace std; void f(int x) { cout << "f" << endl; } void f(const int x) { cout << "f (const)" << endl; } // error: redefinition of 'f' int main() { } 2.…
kgf3JfUtW
  • 13,702
  • 10
  • 57
  • 80
1 2
3
18 19