Skip to content

Convert #include guards to #pragma once; add missing #pragma once #9260

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

Merged
merged 3 commits into from
May 20, 2024

Conversation

dhalbert
Copy link
Collaborator

  • Add #pragma once to any CircuitPython-specific files that didn't have existing #include guards.
  • Convert all CircuitPython-specific include files to use #pragma once instead of regular #include guards.

I was greatly aided in this by the https://github.com/cgmb/guardonce tool

#9257 had previously marked all CircuitPython-specific .c and .h files in their headers. I then applied this recipe:

# Add #pragma once to any .h files that didn't have it or regular 
ag --hh -l "this file is part of the circuitpython" |xargs checkguard | xargs sed -i -e '/\/\/ SPDX-License-Identifier/a\' -e '\' -e '#pragma once'
# I then reviewed the files quickly with gitk.
# A  couple of files after the above had to have a blank line added after `#pragma once`
# and devices/ble_hci/common-hal/_bleio/hci_include/l2cap_internal.h had to be touched up by hand.

# Then convert all include guards to #pragma once, stripping any trailing blank lines.
ag --hh -l "this file is part of the circuitpython" |xargs guard2once -s

@dhalbert dhalbert requested review from tannewt and jepler May 20, 2024 01:58
Copy link

@jepler jepler left a comment

Choose a reason for hiding this comment

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

As best I can tell, the changes are what's intended. github doesn't seem to like loading such a large diff but I did some local git work and it looks sensible.

@jepler jepler merged commit a0e33db into adafruit:main May 20, 2024
512 checks passed
@jepler jepler deleted the pragma-once branch May 20, 2024 10:06
@dhalbert
Copy link
Collaborator Author

dhalbert commented May 20, 2024

There is some build warning here that is being ignored that I need to track down. It doesn't seem to affect the generated code, though. I did a smoke test and various qstrs look fine, so not sure if it's related to qstr generation.

From a local build of pico w, but I see this on any build:

Root pointer registrations updated
GEN build-raspberry_pi_pico_w/genhdr/root_pointers.h
Module registrations updated
GEN build-raspberry_pi_pico_w/genhdr/moduledefs.h
QSTR updated
GEN build-raspberry_pi_pico_w/genhdr/qstrdefs.generated.h
<stdin>:77:9: error: #pragma once in main file [-Werror]
cc1: all warnings being treated as errors

@jepler
Copy link

jepler commented May 20, 2024

sorry for merging this prematurely. I should have left the review but not merged, but I was in a hurry and the board looked green. mea culpa

@dhalbert
Copy link
Collaborator Author

You didn't miss anything! It was green! I only saw the issue when I was doing a build locally for other reasons. I should have done more local testing.

@dhalbert
Copy link
Collaborator Author

I don't think this is actually causing any problems, but I should get rid of the warning.

eightycc pushed a commit that referenced this pull request May 8, 2025
We need to be able to include pin_names.h more than once for it to
work.

Broken by #9260. Fixes #9957
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy