-
Notifications
You must be signed in to change notification settings - Fork 3.6k
add compatibility with clangd for better editing with VSCode #2122
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
base: master
Are you sure you want to change the base?
Conversation
src/util.c
Outdated
| void StoreWordInTwoHalfwords(u16 *h, u32 w) { | ||
| h[0] = (u16)(w); | ||
| h[1] = (u16)(w >> 16); | ||
| } | ||
|
|
||
| void LoadWordFromTwoHalfwords(u16 *h, u32 *w) | ||
| { | ||
| *w = h[0] | (s16)h[1] << 16; | ||
| } | ||
| void LoadWordFromTwoHalfwords(u16 *h, u32 *w) { *w = h[0] | (s16)h[1] << 16; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't checked everything, but did you intend to reformat code like in this example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reformatting (and others) are on accident, VSCode just really wants to format stuff. I will revert the formatting changes.
src/pokemon_storage_system.c
Outdated
| else | ||
| #endif | ||
| lvl = 0; | ||
| lvl = 0; // NOLINT(readability-misleading-indentation) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my opinion, but I kinda hate putting these sorts of "tool-only" comments in the code.
If you're committed to clangd not throwing a spurious warning here, is there a different way the code could be formatted which would read naturally and not throw the warning? Or maybe clangd could be told to assume BUGFIX is defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indenting the line with four spaces is fine for clang, if that's ok for you. I think clangd should have no warnings no matter the setting of BUGFIX.
src/pokedex.c
Outdated
| u8 menuItem; | ||
| u16 *cursorPos; | ||
| u16 *scrollOffset; | ||
| s16 *scrollOffset; // should also |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment is incomplete?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll remove it
src/m4a_tables.c
Outdated
| #define MOD 0xc4 | ||
| #define MOD 0xc4 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you meant to commit this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will revert
src/list_menu.c
Outdated
| subsprites[id].x = (s8) 136; | ||
| subsprites[id].y = (s8) 136; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We format casts as (s8)136 rather than (s8) 136. There's a few other instances in this file, and I think there's a bunch in other files too (usually to do with unsigned vs signed confusion on GF's part).
| #ifndef REGION_MAP_CITY_TILEMAPS_H | ||
| #define REGION_MAP_CITY_TILEMAPS_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of these include guards? The src/data/*.h files would only be #included directly into a single .c file (otherwise you'd get multiple definition errors from the linker), so the guards are misleading imo—they state that it's expected to include this file from multiple places.
| #include <stddef.h> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On a similar note, I get that the idea here is to tell your tools that NULL is in scope, but it seems really sketchy to have #include blocks at the top of files that are intended to be included part-way through a .c file.
As a user, I think it would be very confusing if there's a #include in a src/data/*.h file that isn't a no-op—in that situation you would have names and types that only start existing half-way through your .c file, in a way that would be very surprising.
Obviously none of your #includes function like that (or at least I hope they don't!), but I think it's laying a small trap for future users that aren't as savvy about the conventions in pokeemerald.
src/battle_anim_effects_1.c
Outdated
| #ifdef CLANGD | ||
| #pragma clang diagnostic push | ||
| #pragma clang diagnostic ignored "-Wconstant-conversion" | ||
| #endif | ||
| sprite->data[4] = (sprite->data[6] = GetBattlerSide(gBattleAnimAttacker)) ? 0x300 : 0xFFFFFD00; | ||
| #ifdef CLANGD | ||
| #pragma clang diagnostic pop | ||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some other way this could be written, or is the problem that 0xFFFFFD00 needs to be written literally like that and can't be -0x300 (or failing that, 0xFD00)?
It's a shame to turn one line into eight 😅
include/main.h
Outdated
| #ifndef GUARD_MAIN_H | ||
| #define GUARD_MAIN_H | ||
|
|
||
| #include <stdint.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's stdint.h for?
Description
Configure clangd to allow editing with VSCode. To facilitate this, some declarations are moved around, some types are adjusted and some include guards added.
Compiles to the same rom.
Discord contact info
jendr1k_