+ 10

implicit declaration of global int variables with identical names in C

question to connoisseurs of the C compiler. I played around with the code (author of the AZTECCO code) in which there was an implicit declaration of an int variable, well, like this "i;" - and found this situation of the code that is being compiled and executed: j, k, k, l, m, l, g, n; f () {for (j = 8; j -;) printf ("% d% d", 9-j, j + 2);} int main () { f ();      return 0; } my code (edition of AZTECCO code) https://code.sololearn.com/ciBOhR8Gm4Eo/?ref=app Of course, of interest is a group of global variables declared in an implicit way ... with duplicate names ... the compiler skips this. This is generally normal, maybe I'm not aware of what? AZTECCO code: https://code.sololearn.com/c4CKbw0lM3gh/?ref=app

8th Jan 2020, 4:50 AM
Michail Getmanskiy
Michail Getmanskiy - avatar
4 Réponses
+ 13
Michail Getmanskiy It's just how C is worked in old days. In older versions of C this code can be fine as in C compiler if any declaration is not matched with inbuilt grammar of the language then it takes default int or pointers according to the use. In your code function is uses which by defaults return an integer value so it takes the default type for operations as int declaration. In past it's supposed to do for reducing the code length. This all things are checked at compile and linking time and due to assembly and low level language C support it well In newer version of C the W-Implicit-Error should be come because of use of implicit function and variable declaration. But as sololearn compiler run on gcc and gnu so it's only parse an warning statement Here is an related discussion link https://stackoverflow.com/questions/9182763/implicit-function-declarations-in-c Conpiler always looks for declaration of data type and tried to match with symbol table if not present their then type assign accordingly
8th Jan 2020, 6:04 AM
GAWEN STEASY
GAWEN STEASY - avatar
+ 4
Michail Getmanskiy The author of the code has described this "phenomenon" in answer within the code comments. I see you also wrote a comment in the code. I'm not sure whether there is anything more to discuss or confirm.
8th Jan 2020, 5:54 AM
Ipang
+ 4
Ipang I think Michail Getmanskiy asked about duplicated global names with the same name which is a specific interesting question in my opinion. Coder Kitten answer should be ✔ , it explains well and gives useful references
8th Jan 2020, 8:10 AM
AZTECCO
AZTECCO - avatar
+ 4
AZTECCO Okay I get it 👌
8th Jan 2020, 8:12 AM
Ipang