Dns.h 'dnClient' does not name a type

I will appreciate every help. I found simple example of code with dns library. But for some reason I don’t understand why it dont work. I tryied to find solution on web. I tryied on another laptop with clear arduino IDE instalation without luck. What is the problem?


#include <Dns.h>

DNSClient dnClient;


void setup() {
// put your setup code here, to run once:


void loop() {
// put your main code here, to run repeatedly:


Error message:
dns_test:5:1: error: ‘dnClient’ does not name a type



It uses Ethernet library: Arduino\libraries\Ethernet

With regards Daniel J.

Put the offending line inside the setup function.

With few exceptions, all C/C++ code must be inside a function.

Yes, thank you. This is when you use arduino once a time not frequently.