Skip to content

doWhile.adoc example code is incorrect and will cause "error: ‘x’ undeclared (first use in this function)" #455

Closed
@SeppPenner

Description

@SeppPenner

This code

do
{
  delay(50);          // wait for sensors to stabilize
  x = readSensors();  // check the sensors

} while (x < 100);

will never work? The variable is declared inside the loop and thus not even accessable from the while? See http://tpcg.io/50Rx6f to compile this online.

$gcc -o main *.c
main.c: In function ‘main’:
main.c:8:14: error: ‘x’ undeclared (first use in this function)
} while (x < 100);
^
main.c:8:14: note: each undeclared identifier is reported only once for each function it appears in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions