Pico Problem - not declared in this scope error

Not sure what I'm doing wrong here, but I get the error :-

Pico Blink.ino:5:3: error: 'set_sys_clock_khz' was not declared in this scope

Any idea's anyone? I'm pretty sure that function is in stdlib.h

Thanks

#include <stdlib.h>

void setup() {

  set_sys_clock_khz(100000, true);

}

void loop() {}

Which board did you select?

Raspberry Pi Pico. I just tried a few others, but still the same error.

Hi @dazzer. You need to change this line:

To this:

#include <pico/stdlib.h>

Hey @in0,

Tried, and it works!!

Thanks man. I seriously tried for over an hour to figure this out. I hate to ask as I like to try to learn, but this one tricked me. The IDE knew exactly where it was, so I thought the path was good.

Nice one!!!

You are welcome. I'm glad it is working now.

This is a confusing one because there are multiple stdlib.h files. The one in the GCC toolchain gets preference over the one in the Raspberry Pi Pico SDK when you only specify the file name in the #include directive. So you get a valid #include directive, but not the expected declarations to use in your sketch.

Using the unique relative path to the file in the #include directive forces the compiler to pick the intended file.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.