Skip to content

Commit 60829a1

Browse files
authored
Make examples friendlier for non GCC compilers and fixed slave_mem_i2c.c to compile on boards without I2C pins (#336)
1 parent 9d3fea1 commit 60829a1

File tree

39 files changed

+89
-86
lines changed

39 files changed

+89
-86
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,10 @@ add_subdirectory(hello_world)
2828
add_compile_options(-Wall
2929
-Wno-format # int != int32_t as far as the compiler is concerned because gcc has int32_t as long int
3030
-Wno-unused-function # we have some for the docs that aren't called
31-
-Wno-maybe-uninitialized
3231
)
32+
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
33+
add_compile_options(-Wno-maybe-uninitialized)
34+
endif()
3335

3436
# Hardware-specific examples in subdirectories:
3537
add_subdirectory(adc)

adc/adc_console/adc_console.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ int main(void) {
7272
printf("%03x\n", sample_buf[i]);
7373
break;
7474
}
75-
case 'w':
75+
case 'w': {
7676
printf("\nPress any key to stop wiggling\n");
7777
int i = 1;
7878
gpio_set_dir_all_bits(-1);
@@ -85,6 +85,7 @@ int main(void) {
8585
gpio_set_dir_all_bits(0);
8686
printf("Wiggling halted.\n");
8787
break;
88+
}
8889
case '\n':
8990
case '\r':
9091
break;

adc/microphone_adc/microphone_adc.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,4 @@ int main() {
4444
printf("%.2f\n", adc_raw * ADC_CONVERT);
4545
sleep_ms(10);
4646
}
47-
48-
return 0;
4947
}

adc/onboard_temperature/onboard_temperature.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,4 @@ int main() {
5858
#endif
5959
sleep_ms(990);
6060
}
61-
62-
return 0;
6361
}

flash/cache_perfctr/flash_cache_perfctr.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ int main() {
7979
printf("Hit rate so far: %.1f%%\n", hit * 100.f / access);
8080

8181
printf("Calculate 25th fibonacci number: %d\n", recursive_fibonacci(25));
82-
printf("New hit rate after printf and fibonacci: %.1f%%\n", xip_ctrl_hw->ctr_hit * 100.f / xip_ctrl_hw->ctr_acc);
82+
uint32_t ctr_hit = xip_ctrl_hw->ctr_hit;
83+
uint32_t ctr_acc = xip_ctrl_hw->ctr_acc;
84+
printf("New hit rate after printf and fibonacci: %.1f%%\n", ctr_hit * 100.f / ctr_acc);
8385

8486
check_hit_miss_invalidate();
8587

flash/nuke/nuke.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//
1818
// To the CMakeLists.txt app for this file. Just to be sure, we can check the
1919
// define:
20-
#if !PICO_NO_FLASH
20+
#if !PICO_NO_FLASH && !PICO_COPY_TO_RAM
2121
#error "This example must be built to run from SRAM!"
2222
#endif
2323

gpio/hello_7segment/hello_7segment.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,5 @@ int main() {
8989
sleep_ms(250);
9090
gpio_clr_mask(mask);
9191
}
92-
93-
return 0;
9492
}
9593
/// \end::hello_gpio[]

gpio/hello_gpio_irq/hello_gpio_irq.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ int main() {
2727

2828
// Wait forever
2929
while (1);
30-
31-
return 0;
3230
}
3331

3432

hello_world/serial/hello_serial.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ int main() {
1313
printf("Hello, world!\n");
1414
sleep_ms(1000);
1515
}
16-
return 0;
1716
}

hello_world/usb/hello_usb.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,4 @@ int main() {
1313
printf("Hello, world!\n");
1414
sleep_ms(1000);
1515
}
16-
return 0;
1716
}

0 commit comments

Comments
 (0)