Skip to content

Formatting C/CPP files - #1623

Merged
schaubh merged 11 commits into
AVSLab:developfrom
jfdev001:feature/bsk-1601-formatting-c-cpp-files
Oct 18, 2026
Merged

schaubh merged 11 commits into
AVSLab:developfrom
jfdev001:feature/bsk-1601-formatting-c-cpp-files

Conversation

@jfdev001

@jfdev001 jfdev001 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR has a massive diff so it's critical to review by commit.

The first two commits (777ed71 and 3fe58ce) do the bulk of the adjustments to pre-commit and CI to incorporate clang formatting.

The third commit (230c7b8) clang formats all C/CPP files. No functional changes are made, just formatting.

The fourth commit (197792c) ensures that clang format in the CI occurs only for files that have since been changed by a PR. This avoids checking all C/CPP files for format correctness in the CI.

The fifth commit (e5afd67) updates the documentation accordingly.

Verification

Only formatting changes were made. No tests needed.

Documentation

Updated contributing and coding guidelines accordingly.

Future work

Might make sense to add python formatting as well for any code that is not generated by SWIG.

@jfdev001
jfdev001 requested a review from a team as a code owner October 16, 2026 16:06
@jfdev001

jfdev001 commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

Looks like a build failure. Odd that windows passed. I'm working on a fi xnow (2026-10-16 @ 19:30 CEST)

@schaubh

schaubh commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

All five failed jobs share one cause: include sorting exposed an invalid _POSIX_C_SOURCE definition.

The PR moves #include "GeomagnetismHeader.h" ahead of the system headers in GeomagnetismLibrary.c. That header contains:

#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE
#endif

Because the macro has no value, comparisons in system headers become invalid. The logs show:

The docs and canary builds hit the same compilation failure. Subsequent NOT_BUILT test failures are consequences.

I reproduced this locally using the PR’s exact files. Removing the empty macro definition makes the C syntax check pass; restoring the original include order also passes. Removing the invalid definition is the cleaner fix, subject to full CI validation. I haven’t changed your checkout.

@jfdev001

Copy link
Copy Markdown
Contributor Author

Hi @schaubh. Yup, just saw this also locally. I will remove the macro definition and then push to see how CI behaves.

@jfdev001

Copy link
Copy Markdown
Contributor Author

sphinx is treating warnings as errors. Logs show:

2026-10-16T18:39:30.4206630Z �[91m/Users/runner/work/basilisk/basilisk/docs/source/Documentation/fswAlgorithms/effectorInterfaces/thrMomentumDumping/thrMomentumDumping.rst:2: WARNING: Block quote ends without a blank line; unexpected unindent. [docutils]�[39;49;00m

Fix is described in the warning. I'll try fix and then re-push

@jfdev001

jfdev001 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor Author

I see merge conflicts. I will resolve those locally now. Done as of 2026-10-17 @ 08:45 CEST

@jfdev001
jfdev001 force-pushed the feature/bsk-1601-formatting-c-cpp-files branch from a62f557 to b1f0065 Compare October 17, 2026 06:45
@jfdev001

Copy link
Copy Markdown
Contributor Author

when rebasing i re-encountered the posix define issue, and the fix for that got swallowed into another commit. I will make that change a separate commit so that it is more visible in the git history

@jfdev001
jfdev001 force-pushed the feature/bsk-1601-formatting-c-cpp-files branch from b1f0065 to 8aa38d0 Compare October 17, 2026 08:23
jfdev001 and others added 11 commits October 17, 2026 15:07
Simply called

```
pre-commit run clang-format --all-files
```
Set BreakAfterReturnType to Automatic and reformat affected files
to improve readability. Long signatures can still wrap, and include
sorting remains enabled.
…dentation

Use IndentOnly to preserve comment line breaks. Set continuation
and constructor initializer indentation to four spaces and reformat
affected C/C++ files.

Retain two-space indentation for class access labels.
Replace comma expressions with condition && message in the translating
and spinning body accessors, preserving bounds checks and diagnostics.

Verified both Debug targets rebuild without warnings and both getter
tests pass.
@schaubh
schaubh force-pushed the feature/bsk-1601-formatting-c-cpp-files branch from 8aa38d0 to 06a5757 Compare October 17, 2026 22:45
@schaubh

schaubh commented Oct 17, 2026

Copy link
Copy Markdown
Contributor

I pushed a few changes to the formatting guidelines and small fixes. CI tests are now running. Overall looks very good. I built in Release mode and Debug mode to ensure there were no issues.

@schaubh schaubh self-assigned this Oct 18, 2026
@schaubh schaubh linked an issue Oct 18, 2026 that may be closed by this pull request
@schaubh schaubh added this to Basilisk Oct 18, 2026
@schaubh schaubh moved this to 👀 In review in Basilisk Oct 18, 2026
@schaubh
schaubh merged commit 818bf93 into AVSLab:develop Oct 18, 2026
8 checks passed
@github-project-automation github-project-automation Bot moved this from 👀 In review to ✅ Done in Basilisk Oct 18, 2026
@jfdev001
jfdev001 deleted the feature/bsk-1601-formatting-c-cpp-files branch October 19, 2026 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

Formatting C/C++ files

2 participants