Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework use of pico_cmake_set in board headers to make it slightly less magic/confusing #2397

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

kilograham
Copy link
Contributor

Particularly, the fact that the lines are commented is confusing

  • prefer "pico_cmake_set(var, value)" over "// pico_cmake_set var = value"
  • prefer "pico_cmake_set_default(var, value)" over "// pico_cmake_set_default var = value"
  • move these inside the header include guards as CLion complains

Note that the macros are defined in "pico.h" however that is not explicitly included by the board headers; this will probably confuse some VS code syntax highligting, so lets see how it looks - i'd prefer to avoid having to include a header just for this

…s magic/confusing

- prefer "pico_cmake_set(var, value)" over "// pico_cmake_set var = value"
- prefer "pico_cmake_set_default(var, value)" over "// pico_cmake_set_default var = value"
- move these inside the header include guards as CLion complains

Note that the macros are defined in "pico.h" however that is not explicitly included by the board headers; this
will probably confuse some VS code syntax highligting, so lets see how it looks - i'd prefer to avoid having
to include a header just for this
@kilograham kilograham requested a review from will-v-pi April 4, 2025 18:17
@@ -73,7 +73,7 @@
#endif

// board has 16M onboard flash
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (16 * 1024 * 1024)
pico_cmake_set_default(PICO_FLASH_SIZE_BYTES, 16 * 1024 * 1024)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that this "looks" like a proper macro, is there a risk that people might expect it to behave like a proper macro? E.g. if somebody did:

// board has 16M onboard flash
#define DEFAULT_MEMORY_SIZE (16 * 1024 * 1024)
pico_cmake_set_default(PICO_FLASH_SIZE_BYTES, DEFAULT_MEMORY_SIZE)
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES DEFAULT_MEMORY_SIZE
#endif

would it work as expected?

@lurch
Copy link
Contributor

lurch commented Apr 4, 2025

IMHO it would be great if this PR could also update https://github.com/raspberrypi/pico-sdk/blob/develop/tools/check_board_header.py to cope with this new syntax. That's normally something that I'd do myself, but I'm about to go on holiday 😎

Copy link
Contributor

@will-v-pi will-v-pi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does seem to work fine with VS Code when using compile_commands.json - although it might make people think they can use pico_cmake_set outside of the board headers, so it might be good to add some sort of guard against that? Or change the definition to pico_board_cmake_set to make it clearer that it only works in board headers?

@kilograham
Copy link
Contributor Author

pico_board_cmake_set good idea - this also helps with something that had been bothering me that a commented out new style one looks a lot like an old style one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants