MSVC Compat 1 v2: Reconcile attributes and math macros - #805
Conversation
Introduce PRINTF_FORMAT(fmt, args) macro in new header `lwgeom_config.h` to handle GCC and Clang-specific printf format checking. This improves portability by avoiding direct usage of `__attribute__((format))` in function declarations. Affected functions: - lwnotice - lwerror - lwdebug - GEOSMessageHandler - lwgeom_geos_error
|
@robe2 @strk as mentioned on IRC/Matrix months ago, I also tried to switch from gnu11 to c11 in another branch. It's OK for *BSD (FreeBSD and macOs tested) but not for Linux, because of a problem in PostgreSQL elog.h (sigjmp_buf not defined):
Here's where I stand at the moment. |
📝 WalkthroughWalkthroughA macro for format string checking, Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Application
participant lwgeom_log.h
participant lwgeom_config.h
User->>Application: Calls logging function (e.g., lwnotice)
Application->>lwgeom_log.h: Uses PRINTF_FORMAT macro in declaration
lwgeom_log.h->>lwgeom_config.h: Expands PRINTF_FORMAT for compiler
lwgeom_config.h-->>lwgeom_log.h: Provides attribute or nothing
Application-->>User: Logging proceeds with format string checking (if supported)
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
⏰ Context from checks skipped due to timeout of 90000ms (12)
🔇 Additional comments (8)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
|
@lbartoletti sorry haven't had a chance to look at this. Regarding https://gitea.osgeo.org/gitea/postgis/postgis/pulls/208 I had pushed this pull request over there so we could have more thorough testing. |
|
Oh wait I didn't notice there were 2 so I'll update https://gitea.osgeo.org/gitea/postgis/postgis/pulls/208 with this one |
Okay repointed the gitea one to what you have here so far. |
|
Being worked at gitea |
This PR supersedes https://git.osgeo.org/gitea/postgis/postgis/pulls/208 and #777.
@ralian If I'm not mistaken, you don't need to include _USE_MATH_DEFINES in multiple files. It can be defined once globally. Could you test this PR?
If the AC_DEFINE approach is not sufficient, you can define it by adding
CPPFLAGS="$CPPFLAGS -D_USE_MATH_DEFINES".I'm also proposing an alternative version of the attribute macro that could be reused elsewhere in the codebase.